<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div> <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecLoad.html" class="">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecLoad.html</a> and <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatLoad.html" class="">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatLoad.html</a> define the simple format. <div class=""><br class=""></div><div class=""> There are loaders for Matlab and Python distributed with PETSc so for those two languages you do not need to write your own custom loaders.</div><div class=""><br class=""></div><div class=""> Barry</div><div class=""><br class=""></div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 29, 2020, at 12:32 PM, C B <<a href="mailto:cebau.mail@gmail.com" class="">cebau.mail@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello PETSc community !<div class=""><br class=""></div><div class="">I would like to read in another code a matrix / rhs / sol saved by PETSc.</div><div class="">I am dealing with large matrices and for precision I would like to use the binary format.</div><div class=""><br class=""></div><div class="">To save a matrix I am using the following lines (please let me know if I should make any changes), I am using an old version PETSc 2.1.5 for backward compatibility.</div><div class=""></div><div class=""><br class=""></div><div class=""> ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,PETSC_BINARY_CREATE,&petsc_view);CHKERRQ(ierr);<br class=""> ierr = VecView(solut,petsc_view);CHKERRQ(ierr);<br class=""> ierr = PetscViewerDestroy(petsc_view);CHKERRQ(ierr);<br class=""></div><div class=""><br class=""></div><div class="">And to save a vector: </div><div class=""><br class=""></div><div class=""> ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, filename, PETSC_BINARY_CREATE, &petsc_view);CHKERRQ(ierr);<br class=""> ierr = VecView(solut, petsc_view);CHKERRQ(ierr);<br class=""> ierr = PetscViewerDestroy(petsc_view);CHKERRQ(ierr);<br class=""></div><div class=""><br class=""></div><div class="">The files are saved without any problems, and now I need to write the code to read the binary files.</div><div class="">Please, would anyone point me to the format of these binary files and/or a code snippet to take as an example ? <br class=""></div><div class=""><br class=""></div><div class="">Thank you very much in advance !</div><div class="">Cheers</div></div>
</div></blockquote></div><br class=""></div></body></html>