Actual source code: ex86.c

  1: /*
  2:     Reads in individual PETSc matrix files for each processor and concatinates them
  3:   together into a single file containing the entire matrix
  4: */
 5:  #include petscmat.h
  8: int main(int argc,char **argv)
  9: {
 10:   int         ierr;
 11:   PetscViewer in,out;
 12:   Mat         inmat,outmat;
 13:   char        *infile = "split", *outfile = "together";

 15:   PetscInitialize(&argc,&argv,(char*) 0,0);

 17:   PetscViewerBinaryOpen(PETSC_COMM_SELF,infile,PETSC_BINARY_RDONLY,&in);
 18:   MatLoad(in,MATSEQAIJ,&inmat);
 19:   PetscViewerDestroy(in);

 21:   MatMerge(PETSC_COMM_WORLD,inmat,&outmat);

 23:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,outfile,PETSC_BINARY_CREATE,&out);
 24:   MatView(outmat,out);
 25:   PetscViewerDestroy(out);
 26:   MatDestroy(outmat);

 28:   PetscFinalize();
 29:   return 0;
 30: }
 31: