Actual source code: ex206.c
petsc-3.12.4 2020-02-04
Report Typos and Errors

      1: static char help[] = "Reads binary matrix - twice\n";

      3:  #include <petscmat.h>
      4: int main(int argc,char **args)
      5: {
      6:   Mat               A;
      7:   PetscViewer       fd;                        /* viewer */
      8:   char              file[PETSC_MAX_PATH_LEN];  /* input file name */
      9:   PetscErrorCode    ierr;
     10:   PetscBool         flg;

     12:   PetscInitialize(&argc,&args,(char*)0,help);

     14:   PetscOptionsGetString(NULL,NULL,"-f",file,PETSC_MAX_PATH_LEN,&flg);
     15:   if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate binary file with the -f option");

     17:   MatCreate(PETSC_COMM_WORLD,&A);
     18:   MatSetFromOptions(A);
     19:   PetscPrintf(PETSC_COMM_WORLD, "First MatLoad! \n");
     20:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&fd);
     21:   MatLoad(A,fd);
     22:   PetscViewerDestroy(&fd);
     23:   MatView(A,PETSC_VIEWER_STDOUT_WORLD);

     25:   PetscOptionsGetString(NULL,NULL,"-f2",file,PETSC_MAX_PATH_LEN,&flg);
     26:   PetscPrintf(PETSC_COMM_WORLD, "Second MatLoad! \n");
     27:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&fd);
     28:   MatLoad(A,fd);
     29:   PetscViewerDestroy(&fd);
     30:   MatView(A,PETSC_VIEWER_STDOUT_WORLD);

     32:   MatDestroy(&A);
     33:   PetscFinalize();
     34:   return ierr;
     35: }

     37: /*TEST

     39:    test:
     40:       suffix: aij_1
     41:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
     42:       args: -f ${DATAFILESPATH}/matrices/small -mat_type aij -mat_block_size 1
     43:       filter: grep -v Mat_

     45:    test:
     46:       suffix: aij_2
     47:       nsize: 2
     48:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
     49:       args: -f ${DATAFILESPATH}/matrices/small -mat_type aij -mat_block_size 1
     50:       filter: grep -v Mat_

     52:    test:
     53:       suffix: aij_2_d
     54:       nsize: 2
     55:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
     56:       args: -f ${DATAFILESPATH}/matrices/small -f2 ${DATAFILESPATH}/matrices/smallbs2 -mat_type aij -mat_block_size 1
     57:       filter: grep -v Mat_

     59:    test:
     60:       suffix: baij_1_2
     61:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
     62:       args: -f ${DATAFILESPATH}/matrices/small -mat_type baij -mat_block_size 2
     63:       filter: grep -v Mat_

     65:    test:
     66:       suffix: baij_2_1_d
     67:       nsize: 2
     68:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
     69:       args: -f ${DATAFILESPATH}/matrices/small -f2 ${DATAFILESPATH}/matrices/smallbs2 -mat_type baij -mat_block_size 1
     70:       filter: grep -v Mat_

     72:    test:
     73:       suffix: baij_2_2
     74:       nsize: 2
     75:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
     76:       args: -f ${DATAFILESPATH}/matrices/small -mat_type baij -mat_block_size 2
     77:       filter: grep -v Mat_

     79:    test:
     80:       suffix: baij_2_2_d
     81:       nsize: 2
     82:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
     83:       args: -f ${DATAFILESPATH}/matrices/small -f2 ${DATAFILESPATH}/matrices/smallbs2 -mat_type baij -mat_block_size 2
     84:       filter: grep -v Mat_

     86:    test:
     87:       suffix: sbaij_1_1
     88:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
     89:       args: -f ${DATAFILESPATH}/matrices/small -mat_type sbaij -mat_block_size 1
     90:       filter: grep -v Mat_

     92:    test:
     93:       suffix: sbaij_1_2
     94:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
     95:       args: -f ${DATAFILESPATH}/matrices/small -mat_type sbaij -mat_block_size 2
     96:       filter: grep -v Mat_

     98:    test:
     99:       suffix: sbaij_2_1_d
    100:       nsize: 2
    101:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
    102:       args: -f ${DATAFILESPATH}/matrices/small -f2 ${DATAFILESPATH}/matrices/smallbs2 -mat_type sbaij -mat_block_size 1
    103:       filter: grep -v Mat_

    105:    test:
    106:       suffix: sbaij_2_2
    107:       nsize: 2
    108:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
    109:       args: -f ${DATAFILESPATH}/matrices/small -mat_type sbaij -mat_block_size 2
    110:       filter: grep -v Mat_

    112: TEST*/