Actual source code: ex220.c
petsc-3.13.6 2020-09-29
2: #include <petscmat.h>
4: static char help[PETSC_MAX_PATH_LEN] = "Tests MatLoad() with MatCreateDense() for memory leak ";
6: int main(int argc, char **argv)
7: {
8: PetscErrorCode ierr;
9: PetscViewer viewer;
10: Mat A;
11: char filename[PETSC_MAX_PATH_LEN];
12: PetscBool flg;
14: PetscInitialize(&argc, &argv, (char*)0, help);if (ierr) return ierr;
15: PetscOptionsGetString(NULL, NULL, "-f", filename, sizeof(filename), &flg);
16: if (!flg) SETERRQ(PETSC_COMM_WORLD, 1, "Must indicate a filename for input with the -f option");
18: PetscViewerBinaryOpen(PETSC_COMM_WORLD, filename, FILE_MODE_READ, &viewer);
19: MatCreateDense(PETSC_COMM_WORLD, PETSC_DECIDE, PETSC_DECIDE, 36, 36, NULL, &A);
20: MatLoad(A, viewer);
21: PetscViewerDestroy(&viewer);
22: MatDestroy(&A);
23: PetscFinalize();
24: return ierr;
25: }
27: /*TEST
29: test:
30: requires: double !complex !define(PETSC_USE_64BIT_INDICES) datafilespath
31: args: -f ${DATAFILESPATH}/matrices/small
33: TEST*/