Actual source code: ex190.c

petsc-3.14.6 2021-03-30
Report Typos and Errors
  1: static char help[] = "Tests MatLoad() with uneven dimensions set in program\n\n";

  3: #include <petscmat.h>

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

 14:   PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;
 15:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);

 17:   /* Determine files from which we read the matrix */
 18:   PetscOptionsGetString(NULL,NULL,"-f",file,sizeof(file),&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:   MatSetFromOptions(A);
 25:   MatSetBlockSize(A,2);
 26:   if (!rank) {
 27:     MatSetSizes(A, 4, PETSC_DETERMINE, PETSC_DETERMINE,PETSC_DETERMINE);
 28:   } else {
 29:     MatSetSizes(A, 8, PETSC_DETERMINE, PETSC_DETERMINE,PETSC_DETERMINE);
 30:   }
 31:   MatLoad(A,fd);
 32:   PetscViewerDestroy(&fd);
 33:   MatDestroy(&A);
 34:   PetscFinalize();
 35:   return ierr;
 36: }


 39: /*TEST

 41:       test:
 42:          nsize: 2
 43:          args: -mat_type aij -mat_view -f ${wPETSC_DIR}/share/petsc/datafiles/matrices/ns-real-int32-float64
 44:          requires: double !complex !define(PETSC_USE_64BIT_INDICES)

 46:       test:
 47:          suffix: 2
 48:          nsize: 2
 49:          args: -mat_type baij -mat_view -f ${wPETSC_DIR}/share/petsc/datafiles/matrices/ns-real-int32-float64
 50:          requires: double !complex !define(PETSC_USE_64BIT_INDICES)

 52:       test:
 53:          suffix: 3
 54:          nsize: 2
 55:          args: -mat_type sbaij -mat_view -f ${wPETSC_DIR}/share/petsc/datafiles/matrices/ns-real-int32-float64
 56:          requires: double !complex !define(PETSC_USE_64BIT_INDICES)

 58: TEST*/