Writes to a binary file.
fd - the file
p - the buffer
n - the number of items to write
type - the type of items to read (
PetscBinaryWrite() uses byte swapping to work on all machines; the files
are written using big-endian ordering to the file. On little-endian machines the numbers
are converted to the big-endian format when they are written to disk.
When PETSc is ./configure with –with-64-bit-indices the integers are written to the
file as 64 bit integers, this means they can only be read back in when the option –with-64-bit-indices
If running with __float128 precision the output is in __float128 unless one uses the -binary_write_double option
The Buffer p should be read-write buffer, and not static data. This way, byte-swapping is done in-place, and then the buffer is written to the file.
This routine restores the original contents of the buffer, after it is written to the file. This is done by byte-swapping in-place the second time.
Because byte-swapping may be done on the values in data it cannot be declared const