Date: 2022-03-04T17:38:17+00:00

Actual source code: matio.c

      1: #include <petscviewer.h>
      2: #include <petsc/private/matimpl.h>

      4: PetscErrorCode MatView_Binary_BlockSizes(Mat mat,PetscViewer viewer)
      5: {
      6:   FILE           *info;
      7:   PetscMPIInt    rank;
      8:   PetscInt       rbs,cbs;

     12:   MatGetBlockSizes(mat,&rbs,&cbs);
     13:   PetscViewerBinaryGetInfoPointer(viewer,&info);
     14:   MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank);
     15:   if (rank == 0 && info) {
     16:     if (rbs != cbs) {PetscFPrintf(PETSC_COMM_SELF,info,"-matload_block_size %D,%D\n",rbs,cbs);}
     17:     else            {PetscFPrintf(PETSC_COMM_SELF,info,"-matload_block_size %D\n",rbs);}
     18:   }
     19:   return(0);
     20: }

     22: PetscErrorCode MatLoad_Binary_BlockSizes(Mat mat,PetscViewer viewer)
     23: {
     24:   PetscInt       rbs,cbs,bs[2],n = 2;
     25:   PetscBool      set;

     29:   /* get current block sizes */
     30:   MatGetBlockSizes(mat,&rbs,&cbs);
     31:   bs[0] = rbs; bs[1] = cbs;
     32:   /* get block sizes from the options database */
     33:   PetscOptionsBegin(PetscObjectComm((PetscObject)viewer),NULL,"Options for loading matrix block size","Mat");
     34:   PetscOptionsIntArray("-matload_block_size","Set the block size used to store the matrix","MatLoad",bs,&n,&set);
     35:   PetscOptionsEnd();
     36:   if (!set) return(0);
     37:   if (n == 1) bs[1] = bs[0]; /* to support -matload_block_size <bs> */
     38:   /* set matrix block sizes */
     39:   if (bs[0] > 0) rbs = bs[0];
     40:   if (bs[1] > 0) cbs = bs[1];
     41:   MatSetBlockSizes(mat,rbs,cbs);
     42:   return(0);
     43: }