<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'>
I am using the following sequence of commands to write a Vec b to a binary file&nbsp; and then eventually read it in MATLAB, but I get an error when I try writing this vector to a file in PETSc.<br><br>ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, filesol, FILE_MODE_WRITE, &amp;binviewersol) ; CHKERRQ(ierr) ;&nbsp;&nbsp;&nbsp; <br>ierr = PetscViewerBinaryGetDescriptor(binviewersol, &amp;fd); CHKERRQ(ierr) ;<br>ierr = PetscBinaryWrite(fd, b, 5, PETSC_SCALAR, PETSC_FALSE);&nbsp;&nbsp;&nbsp; CHKERRQ(ierr) ;<br><br><br><br>Here is the error :<br><br><br>[1]PETSC ERROR: Write to file failed!<br>[1]PETSC ERROR: Error writing to file.!<br><br><br><br>NOTE : Petsc is configured with complex option and Vec b has complex entries. Length of Vec b is 5 .<br>                                               </div></body>
</html>