xref: /petsc/src/dm/tests/ex13.c (revision b122ec5aa1bd4469eb4e0673542fb7de3f411254)
1 
2 static char help[] = "Tests loading DM vector from file.\n\n";
3 
4 /*
5     ex14.c writes out the DMDA and vector read by this program.
6 */
7 
8 #include <petscdmda.h>
9 
10 int main(int argc,char **argv)
11 {
12   PetscInt       M = PETSC_DECIDE,N = PETSC_DECIDE;
13   DM             da;
14   Vec            global;
15   PetscViewer    bviewer;
16 
17   CHKERRQ(PetscInitialize(&argc,&argv,(char*)0,help));
18   CHKERRQ(PetscOptionsGetInt(NULL,NULL,"-M",&M,NULL));
19   CHKERRQ(PetscOptionsGetInt(NULL,NULL,"-N",&N,NULL));
20 
21   CHKERRQ(PetscViewerBinaryOpen(PETSC_COMM_WORLD,"daoutput",FILE_MODE_READ,&bviewer));
22   CHKERRQ(DMCreate(PETSC_COMM_WORLD,&da));
23 
24   CHKERRQ(DMLoad(da,bviewer));
25   CHKERRQ(DMCreateGlobalVector(da,&global));
26   CHKERRQ(VecLoad(global,bviewer));
27   CHKERRQ(PetscViewerDestroy(&bviewer));
28 
29   CHKERRQ(VecView(global,PETSC_VIEWER_DRAW_WORLD));
30 
31   /* Free memory */
32   CHKERRQ(VecDestroy(&global));
33   CHKERRQ(DMDestroy(&da));
34   CHKERRQ(PetscFinalize());
35   return 0;
36 }
37