<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 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, &binviewersol) ; CHKERRQ(ierr) ; <br>ierr = PetscViewerBinaryGetDescriptor(binviewersol, &fd); CHKERRQ(ierr) ;<br>ierr = PetscBinaryWrite(fd, b, 5, PETSC_SCALAR, PETSC_FALSE); 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>