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: MatCreate(PETSC_COMM_WORLD,&inmat);
21: MatSetType(inmat,MATSEQAIJ);
22: MatLoad(inmat,in);
23: PetscViewerDestroy(&in);
25: MatMerge(PETSC_COMM_WORLD,inmat,PETSC_DECIDE,MAT_INITIAL_MATRIX,&outmat);
27: PetscViewerBinaryOpen(PETSC_COMM_WORLD,outfile,FILE_MODE_WRITE,&out);
28: MatView(outmat,out);
29: PetscViewerDestroy(&out);
30: MatDestroy(&outmat);
32: PetscFinalize();
33: return 0;
34: }
35: