<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
<br><br><div>
Hello Barry,<br>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 :<br>[0]PETSC ERROR: Read from file failed!<br>[0]PETSC ERROR: Read past end of file!<br><br><br>You mentioned in your reply that "reading ASCII files in parallel is not viable. " <br>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.<br></div>Did you mean that I should avoid doing something like this :<br>ierr = MatLoad(binviewer, MATMPIAIJ, &C) ; CHKERRQ(ierr) ;<br><br>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)? <br>My ultimate goal is the following, which I am copying here from my previous email :<br> 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. <br><br>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. <br><br>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.<br><br>Thank you for your help.<br><br>-Amrit<br><br><br><br><div>> From: bsmith@mcs.anl.gov<br>> Date: Sun, 4 Sep 2011 21:14:24 -0500<br>> To: petsc-users@mcs.anl.gov<br>> Subject: Re: [petsc-users] Write complex matrix/vector from Matlab<br>> <br>> <br>> Amrit,<br>> <br>> 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 <br>> <br>> One can use the following tarball. It will correspond to<br>> petsc-3.2 sources for the next few days. And i've set it up to be<br>> updated every 3 hours [from the sources in mercurial].<br>> <br>> http://ftp.mcs.anl.gov/pub/petsc/petsc-dev.tar.gz<br>> <br>> or<br>> <br>> > <br>> > You can find the PETSc 3.2 release candidate via Mecurial at:<br>> >> <br>> >> ssh://petsc@petsc.cs.iit.edu//hg/petsc/releases/petsc-3.2 or http://petsc.cs.iit.edu/petsc/releases/petsc-3.2<br>> >> ssh://petsc@petsc.cs.iit.edu//hg/petsc/releases/BuildSystem-3.2 or http://petsc.cs.iit.edu/petsc/releases/BuildSystem-3.2<br>> <br>> Should you have problems reading the complex matrices/vectors saved from MATLAB please send all information to petsc-maint@mcs.anl.gov<br>> <br>> 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.<br>> <br>> <br>> Barry<br>> <br>> On Sep 4, 2011, at 9:05 PM, amrit poudel wrote:<br>> <br>> > <br>> > Hello everyone,<br>> > <br>> > 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?<br>> > 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 :(<br>> > <br>> > 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 :<br>> > <br>> > PetscViewer binviewer ;<br>> > Mat C ;<br>> > char fileC[PETSC_MAX_PATH_LEN] ;<br>> > <br>> > ierr = PetscOptionsGetString(PETSC_NULL, "-fC", fileC, PETSC_MAX_PATH_LEN-1, PETSC_NULL) ; CHKERRQ(ierr) ;<br>> > <br>> > ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, fileC, FILE_MODE_READ, &binviewer) ; CHKERRQ(ierr) ;<br>> > <br>> > ierr = MatLoad(binviewer, MATMPIAIJ, &C) ; CHKERRQ(ierr) ;<br>> > <br>> > <br>> > I must add that I compiled PETSc with complex numbers. <br>> > <br>> > 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.<br>> > <br>> > 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. <br>> > <br>> > I will truly appreciate any help or a pointer in this regard.<br>> > <br>> > Thank you.<br>> > <br>> > Amrit <br>> > <br>> <br></div>                                            </div></body>
</html>