1 static char help[] = "Tests binary MatView() for MPIDENSE matrices \n\n";
2
3 #include <petscmat.h>
4
main(int argc,char ** args)5 int main(int argc, char **args)
6 {
7 Mat A;
8 PetscViewer viewer;
9 char inputfile[256], outputfile[256];
10 PetscBool flg;
11
12 PetscFunctionBeginUser;
13 PetscCall(PetscInitialize(&argc, &args, NULL, help));
14 PetscCall(PetscOptionsGetString(NULL, NULL, "-inputfile", inputfile, sizeof(inputfile), &flg));
15 PetscCall(PetscOptionsGetString(NULL, NULL, "-outputfile", outputfile, sizeof(outputfile), &flg));
16 PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD, inputfile, FILE_MODE_READ, &viewer));
17 PetscCall(MatCreate(PETSC_COMM_WORLD, &A));
18 PetscCall(MatSetType(A, MATDENSE));
19 PetscCall(MatLoad(A, viewer));
20 PetscCall(PetscViewerDestroy(&viewer));
21 PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD, outputfile, FILE_MODE_WRITE, &viewer));
22 PetscCall(MatView(A, viewer));
23 PetscCall(PetscViewerDestroy(&viewer));
24 PetscCall(PetscFinalize());
25 return 0;
26 }
27