1 static char help[] = "Tests binary MatView() for MPIDENSE matrices \n\n"; 2 3 #include <petscmat.h> 4 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 PetscCall(PetscInitialize(&argc,&args,(char*)0,help)); 13 PetscCall(PetscOptionsGetString(NULL,NULL,"-inputfile",inputfile,sizeof(inputfile),&flg)); 14 PetscCall(PetscOptionsGetString(NULL,NULL,"-outputfile",outputfile,sizeof(outputfile),&flg)); 15 PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,inputfile,FILE_MODE_READ,&viewer)); 16 PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); 17 PetscCall(MatSetType(A,MATDENSE)); 18 PetscCall(MatLoad(A,viewer)); 19 PetscCall(PetscViewerDestroy(&viewer)); 20 PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,outputfile,FILE_MODE_WRITE,&viewer)); 21 PetscCall(MatView(A,viewer)); 22 PetscCall(PetscViewerDestroy(&viewer)); 23 PetscCall(PetscFinalize()); 24 return 0; 25 } 26