Actual source code: ex180.c

petsc-3.8.4 2018-03-24
Report Typos and Errors
  1: static char help[] = "Tests MatLoad() with blocksize set in in program\n\n";

  3:  #include <petscmat.h>

  5: PetscInt main(PetscInt argc,char **args)
  6: {
  7:   Mat            A;
  8:   PetscViewer    fd;
  9:   char           file[PETSC_MAX_PATH_LEN];
 11:   PetscBool      flg;

 13:   PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;
 14:   /* Determine files from which we read the matrix */
 15:   PetscOptionsGetString(NULL,NULL,"-f",file,PETSC_MAX_PATH_LEN,&flg);
 16:   if (!flg) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_USER,"Must indicate binary file with the -f");

 18:   /* Load matrices */
 19:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&fd);
 20:   MatCreate(PETSC_COMM_WORLD,&A);
 21:   MatSetType(A,MATSBAIJ);
 22:   MatSetFromOptions(A);
 23:   MatSetBlockSize(A,2);
 24:   MatLoad(A,fd);
 25:   PetscViewerDestroy(&fd);
 26:   MatDestroy(&A);
 27:   PetscFinalize();
 28:   return ierr;
 29: }