Actual source code: ex4.c
2: static char help[] = "Tests AOData loading.\n\n";
4: #include petscao.h
8: int main(int argc,char **argv)
9: {
10: AOData aodata;
11: PetscViewer binary;
12: int ierr,indices[4],*intv,i,rank;
14: PetscInitialize(&argc,&argv,(char*)0,help);
15: MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
17: /*
18: Load the database from the file
19: */
20: PetscViewerBinaryOpen(PETSC_COMM_WORLD,"dataoutput",PETSC_FILE_RDONLY,&binary);
21: AODataLoadBasic(binary,&aodata);
22: PetscViewerDestroy(binary);
24: /*
25: Access part of the data
26: */
27: indices[0] = 0; indices[1] = 2; indices[2] = 1; indices[3] = 5;
28: AODataSegmentGet(aodata,"key1","seg1",4,indices,(void **)&intv);
29: for (i=0; i<4; i++) {
30: PetscSynchronizedPrintf(PETSC_COMM_WORLD,"[%d] %D %D\n",rank,i,intv[i]);
31: }
32: PetscSynchronizedFlush(PETSC_COMM_WORLD);
33: AODataSegmentRestore(aodata,"key1","seg1",4,indices,(void **)&intv);
34:
35: AODataDestroy(aodata);
37: PetscFinalize();
38: return 0;
39: }
40: