petsc-3.14.6 2021-03-30
PetscBinaryWrite
Writes to a binary file.
Synopsis
PetscErrorCode PetscBinaryWrite(int fd,const void *p,PetscInt n,PetscDataType type)
Not Collective
Input Parameters
| fd | - the file
|
| p | - the buffer
|
| n | - the number of items to write
|
| type | - the type of items to read (PETSC_INT, PETSC_DOUBLE or PETSC_SCALAR)
|
Notes
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
is used.
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
See Also
PetscBinaryRead(), PetscBinaryOpen(), PetscBinaryClose(), PetscViewerBinaryGetDescriptor(), PetscBinarySynchronizedWrite(),
PetscBinarySynchronizedRead(), PetscBinarySynchronizedSeek()
Level
advanced
Location
src/sys/fileio/sysio.c
Examples
src/vec/vec/tutorials/ex6.c.html
src/vec/vec/tutorials/ex6f.F90.html
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages