Actual source code: ex3.c
1: static char help[] = "Tests ISSetBlockSize() on ISBlock().\n\n";
3: #include <petscis.h>
4: #include <petscviewer.h>
6: int main(int argc, char **argv)
7: {
8: PetscInt bs = 2, n = 3, ix[3] = {1, 7, 9};
9: const PetscInt *indices;
10: IS is;
11: PetscBool broken = PETSC_FALSE;
13: PetscFunctionBeginUser;
14: PetscCall(PetscInitialize(&argc, &argv, (char *)0, help));
15: PetscCall(PetscOptionsGetBool(NULL, NULL, "-broken", &broken, NULL));
16: PetscCall(ISCreateBlock(PETSC_COMM_SELF, bs, n, ix, PETSC_COPY_VALUES, &is));
17: PetscCall(ISGetIndices(is, &indices));
18: PetscCall(PetscIntView(bs * 3, indices, NULL));
19: PetscCall(ISRestoreIndices(is, &indices));
20: if (broken) {
21: PetscCall(ISSetBlockSize(is, 3));
22: PetscCall(ISGetIndices(is, &indices));
23: PetscCall(PetscIntView(bs * 3, indices, NULL));
24: PetscCall(ISRestoreIndices(is, &indices));
25: }
26: PetscCall(ISDestroy(&is));
28: PetscCall(PetscFinalize());
29: return 0;
30: }
32: /*TEST
34: test:
36: test:
37: suffix: 2
38: args: -broken
39: filter: Error: grep -o "[0]PETSC ERROR: Object is in wrong state"
41: TEST*/