On Sep 4, 2011, at 9:52 PM, amrit poudel wrote: > > > Hello Barry, > Thanks for your quick response. The one that I have compiled was > PETSc-3.1-p8. Does this mean I will need to re-compile the most recent 3.2 > version to get this working? I was surprised due to the fact that > PetscBinaryWrite.m did not even work for REAL matrix. The error I got while > reading the file in PETSc was : > [0]PETSC ERROR: Read from file failed! > [0]PETSC ERROR: Read past end of file! > Please send your MATLAB code that generates the matrix to petsc-maint at mcs.anl.gov saving real matrices and reading them in PETSc should not be an issue. This should all work with petsc-3.1 > > You mentioned in your reply that "reading ASCII files in parallel is not > viable. " > Does any part of my code show that I am trying to do this? I am asking this > just to make sure that I am doing the right thing and not making any such > mistakes. > Did you mean that I should avoid doing something like this : > ierr = MatLoad(binviewer, MATMPIAIJ, &C) ; CHKERRQ(ierr) ;
No, this is correct; this is reading a binary file. It is only reading ASCII sparse matrices in parallel that is a problem. > > Is this really not storing a sparse matrix(if C is sparse) in parallel across > different processors( if I were running this on a multi-processor computer or > a cluster)? > My ultimate goal is the following, which I am copying here from my previous > email : > I plan on assembling my matrix (very large square sparse matrix, size greater > than 1e+8) in MATLAB, which does not take too long to assemble in MATLAB at > all. Then I will write the matrix to a binary file and read that in PETSc and > solve a very large linear system of equations in parallel in PETSc using MPI. > > All I want to make sure is be able to read the matrix in PETSc and then have > it distribute over different processors and then solve the linear system. Yes, this is all supported and you should be able to do it. Barry > > Sorry for repeating my goals here again, but I was just trying to get any > feedback whether this is really the way to work with PETSc. > > Thank you for your help. > > -Amrit > > > > > From: bsmith at mcs.anl.gov > > Date: Sun, 4 Sep 2011 21:14:24 -0500 > > To: petsc-users at mcs.anl.gov > > Subject: Re: [petsc-users] Write complex matrix/vector from Matlab > > > > > > Amrit, > > > > We have just recently made sure that PetscBinaryWrite.m and > > PetscBinaryRead.m fully support complex numbers; you can access the release > > candidate for PETSc 3.2 for this support > > > > One can use the following tarball. It will correspond to > > petsc-3.2 sources for the next few days. And i've set it up to be > > updated every 3 hours [from the sources in mercurial]. > > > > http://ftp.mcs.anl.gov/pub/petsc/petsc-dev.tar.gz > > > > or > > > > > > > > You can find the PETSc 3.2 release candidate via Mecurial at: > > >> > > >> ssh://petsc at petsc.cs.iit.edu//hg/petsc/releases/petsc-3.2 or > > >> http://petsc.cs.iit.edu/petsc/releases/petsc-3.2 > > >> ssh://petsc at petsc.cs.iit.edu//hg/petsc/releases/BuildSystem-3.2 or > > >> http://petsc.cs.iit.edu/petsc/releases/BuildSystem-3.2 > > > > Should you have problems reading the complex matrices/vectors saved from > > MATLAB please send all information to petsc-maint at mcs.anl.gov > > > > We do not support the Matrix Market sparse format because it is not > > scalable for large matrices (i.e. it is too slow) ; reading ASCII files in > > parallel is not viable. > > > > > > Barry > > > > On Sep 4, 2011, at 9:05 PM, amrit poudel wrote: > > > > > > > > Hello everyone, > > > > > > Does anyone here know how one can write a complex or real, matrix or > > > vector (matrix could be sparse or full) in MATLAB to a binary file such > > > that it can be read correctly by PETSc? > > > I tried using PetscBinaryWrite.m that came with PETSc ( /bin/matlab) to > > > write a simple real (or complex), full (or sparse) matrix in binary file > > > named 'matrix.dat' and tried reading it in PETSc, but it absolutely does > > > not work :( > > > > > > I did PetscBinaryWrite('matrix.dat', C) to write a matrix C in an empty > > > file named 'matrix.dat' in MATLAB. Then I tried reading 'matrix.dat' file > > > in PETSc using the following command : > > > > > > PetscViewer binviewer ; > > > Mat C ; > > > char fileC[PETSC_MAX_PATH_LEN] ; > > > > > > ierr = PetscOptionsGetString(PETSC_NULL, "-fC", fileC, > > > PETSC_MAX_PATH_LEN-1, PETSC_NULL) ; CHKERRQ(ierr) ; > > > > > > ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, fileC, FILE_MODE_READ, > > > &binviewer) ; CHKERRQ(ierr) ; > > > > > > ierr = MatLoad(binviewer, MATMPIAIJ, &C) ; CHKERRQ(ierr) ; > > > > > > > > > I must add that I compiled PETSc with complex numbers. > > > > > > I plan on assembling my matrix (very large square sparse matrix, size > > > greater than 1e+8) in MATLAB, which does not take too long to assemble in > > > MATLAB at all. Then I will write the matrix to a binary file and read > > > that in PETSc and solve a very large linear system of equations in > > > parallel in PETSc using MPI. Hence, I really need to be able to write the > > > matrix in MATLAB to a binary file such that PETSc can correctly read the > > > matrix. > > > > > > I am really surprised to find out that PETSc cannot read/write a matrix > > > or vector, full or sparse, real or complex in MATRIX MARKET FORMAT. I > > > have gone though the manual, googled around quite a bit, but I just have > > > not found anything useful. > > > > > > I will truly appreciate any help or a pointer in this regard. > > > > > > Thank you. > > > > > > Amrit > > > > >
