Actual source code: ex13.c
2: static char help[] = "Tests loading DM vector from file.\n\n";
4: /*
5: ex14.c writes out the DMDA and vector read by this program.
6: */
8: #include <petscdmda.h>
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;
17: PetscFunctionBeginUser;
18: PetscCall(PetscInitialize(&argc, &argv, (char *)0, help));
19: PetscCall(PetscOptionsGetInt(NULL, NULL, "-M", &M, NULL));
20: PetscCall(PetscOptionsGetInt(NULL, NULL, "-N", &N, NULL));
22: PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD, "daoutput", FILE_MODE_READ, &bviewer));
23: PetscCall(DMCreate(PETSC_COMM_WORLD, &da));
25: PetscCall(DMLoad(da, bviewer));
26: PetscCall(DMCreateGlobalVector(da, &global));
27: PetscCall(VecLoad(global, bviewer));
28: PetscCall(PetscViewerDestroy(&bviewer));
30: PetscCall(VecView(global, PETSC_VIEWER_DRAW_WORLD));
32: /* Free memory */
33: PetscCall(VecDestroy(&global));
34: PetscCall(DMDestroy(&da));
35: PetscCall(PetscFinalize());
36: return 0;
37: }