Actual source code: ex119.c
petsc-3.14.6 2021-03-30
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,sizeof(inputfile),&flg);
16: PetscOptionsGetString(NULL,NULL,"-outputfile",outputfile,sizeof(outputfile),&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: }