check mat/examples/tests/ex72.c,ex50.c for examples. Also ksp/ksp/examples/tutorials/ex10.c - for loading up this matrix and solving parallely.
Satish On Wed, 29 Sep 2010, Jed Brown wrote: > On Wed, Sep 29, 2010 at 11:46, Moinier, Pierre (UK) > <Pierre.Moinier at baesystems.com> wrote: > > I have a Matrix and a Right Hand Side (RHS) in an ASCII format stored in?2 > > different files. I have written the code that reads the data and solve the > > system in sequential. I would like to solve the same problem in parallel. I > > read the FAQ section that says: > > > > Never read or write in parallel an ASCII matrix file, instead for reading: > > read in sequentially then save the matrix with the binary viewer > > PetscBinaryViewerOpen() and load the matrix in parallel with MatLoad(). > > > > So far, I did not manage to implement this. Could any one help me? > > With your matrix assembled in serial: > > ierr = > PetscViewerBinaryOpen(PETSC_COMM_WORLD,"A.dat",FILE_MODE_WRITE,&viewer);CHKERRQ(ierr); > ierr = MatView(A,viewer);CHKERRQ(ierr); > ierr = PetscViewerDestroy(viewer);CHKERRQ(ierr); > > In parallel: > > ierr = > PetscViewerBinaryOpen(PETSC_COMM_WORLD,"A.dat",FILE_MODE_READ,&viewer);CHKERRQ(ierr); > ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); > ierr = MatLoad(A,viewer);CHKERRQ(ierr); > ierr = PetscViewerDestroy(viewer);CHKERRQ(ierr); > ierr = KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); > > > Jed >
