Actual source code: ex180.c
petsc-3.7.3 2016-08-01
1: static char help[] = "Tests MatLoad() with blocksize set in in program\n\n";
3: #include <petscmat.h>
7: PetscInt main(PetscInt argc,char **args)
8: {
9: Mat A;
10: PetscViewer fd;
11: char file[PETSC_MAX_PATH_LEN];
13: PetscBool flg;
15: PetscInitialize(&argc,&args,(char*)0,help);
17: /* Determine files from which we read the matrix */
18: PetscOptionsGetString(NULL,NULL,"-f",file,PETSC_MAX_PATH_LEN,&flg);
19: if (!flg) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_USER,"Must indicate binary file with the -f");
21: /* Load matrices */
22: PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&fd);
23: MatCreate(PETSC_COMM_WORLD,&A);
24: MatSetType(A,MATSBAIJ);
25: MatSetFromOptions(A);
26: MatSetBlockSize(A,2);
27: MatLoad(A,fd);
28: PetscViewerDestroy(&fd);
29: MatDestroy(&A);
30: PetscFinalize();
31: return 0;
32: }