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