On Tue, 4 Dec 2018 at 19:53, Matthew Knepley <knep...@gmail.com> wrote:
> On Tue, Dec 4, 2018 at 11:11 AM Lisandro Dalcin via petsc-users < > petsc-users@mcs.anl.gov> wrote: > >> PetscByteSwap ? But be careful, you should (1) vec get array, byteswap, >> vec restore array, (2) view, (3) vec get array, byteswap, vec restore >> array. Of course, if you do not care about the final Vec contents, you can >> just omit step (3) and let it be, let it be... >> >> PS: Eventually, PETSc binary viewers should gain an API like >> PetscViewerBinarySetByteOrder(viewer, PETSC_LITTLE_ENDIAN) ... >> > > Note that this enables exactly what we wanted to avoid, namely binary > files that an incompatible with some installations. > > 1) As a confessed libertarian (not to be confused with liberal), IMHO, we should not prevent power users to do something if they explicitly ask for it. Maybe someone has to dump a binary file in little endian with no headers, so that some other crappy software that do not care about endianness can happily read the file and do something with it. Why would we not add the feature (at least if someone contributes it)? 2) The whole native binary I/O in PETSc is messy. 3) In an ideal word, every PETSc binary file should start with a header 8bitEndianFlag,sizeof(PetscInt),sizeof(PetscReal),sizeof(PetscScalar), And maybe readers should handle gracefully binary files produced by PETSc builds with different integer/real sizes. -- Lisandro Dalcin ============ Research Scientist Computer, Electrical and Mathematical Sciences & Engineering (CEMSE) Extreme Computing Research Center (ECRC) King Abdullah University of Science and Technology (KAUST) http://ecrc.kaust.edu.sa/ 4700 King Abdullah University of Science and Technology al-Khawarizmi Bldg (Bldg 1), Office # 0109 Thuwal 23955-6900, Kingdom of Saudi Arabia http://www.kaust.edu.sa Office Phone: +966 12 808-0459