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

  5:     Do NOT use this, use ../ex5.c instead, it is MUCH more memory efficient
  6: */
 7:  #include petscmat.h
 10: int main(int argc,char **argv)
 11: {
 13:   PetscViewer    in,out;
 14:   Mat            inmat,outmat;
 15:   const char     *infile = "split", *outfile = "together";

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

 19:   PetscViewerBinaryOpen(PETSC_COMM_SELF,infile,FILE_MODE_READ,&in);
 20:   MatLoad(in,MATSEQAIJ,&inmat);
 21:   PetscViewerDestroy(in);

 23:   MatMerge(PETSC_COMM_WORLD,inmat,PETSC_DECIDE,MAT_INITIAL_MATRIX,&outmat);

 25:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,outfile,FILE_MODE_WRITE,&out);
 26:   MatView(outmat,out);
 27:   PetscViewerDestroy(out);
 28:   MatDestroy(outmat);

 30:   PetscFinalize();
 31:   return 0;
 32: }
 33: