Actual source code: ex12.c
2: static char help[] = "Tests HDF5 ISView() / ISLoad(), and ISSetLayout()\n\n";
4: #include <petscis.h>
5: #include <petscviewerhdf5.h>
7: int main(int argc, char **argv)
8: {
9: const char filename[] = "ex12.h5";
10: const char objname[] = "is0";
11: IS is0, is1;
12: PetscLayout map;
13: PetscViewer viewer;
14: PetscMPIInt size, rank;
15: MPI_Comm comm;
18: PetscInitialize(&argc, &argv, (char *)0, help);
19: comm = PETSC_COMM_WORLD;
20: MPI_Comm_size(comm, &size);
21: MPI_Comm_rank(comm, &rank);
23: {
24: PetscInt *idx, i, n, start, end;
26: n = rank + 2;
27: PetscCalloc1(n, &idx);
28: ISCreateGeneral(comm, n, idx, PETSC_OWN_POINTER, &is0);
29: PetscObjectSetName((PetscObject)is0, objname);
30: ISGetLayout(is0, &map);
31: PetscLayoutGetRange(map, &start, &end);
33: for (i = 0; i < n; i++) idx[i] = i + start;
34: }
36: PetscViewerHDF5Open(comm, filename, FILE_MODE_WRITE, &viewer);
37: ISView(is0, viewer);
39: ISCreate(comm, &is1);
40: PetscObjectSetName((PetscObject)is1, objname);
41: ISSetLayout(is1, map);
42: ISLoad(is1, viewer);
44: {
45: PetscBool flg;
47: ISEqual(is0, is1, &flg);
49: }
51: ISDestroy(&is0);
52: ISDestroy(&is1);
53: PetscViewerDestroy(&viewer);
54: PetscFinalize();
55: return 0;
56: }
58: /*TEST
60: build:
61: requires: hdf5
62: test:
63: nsize: {{1 3}}
65: TEST*/