petsc-3.7.1 2016-05-15
Report Typos and Errors

PetscBinaryWrite

Writes to a binary file.

Synopsis

PetscErrorCode  PetscBinaryWrite(int fd,void *p,PetscInt n,PetscDataType type,PetscBool  istemp)
Not Collective Many br

Input Parameters

fd - the file Many br
p - the buffer Many br
n - the number of items to write Many br
type - the type of items to read (PETSC_INT, PETSC_DOUBLE or PETSC_SCALAR) Many br
istemp - PETSC_FALSE if buffer data should be preserved, PETSC_TRUE otherwise. Many br

Many br

Notes

PetscBinaryWrite() uses byte swapping to work on all machines; the files Many brare written using big-endian ordering to the file. On small-endian machines the numbers Many brare converted to the big-endian format when they are written to disk. Many brWhen PETSc is ./configure with --with-64bit-indices the integers are written to the Many brfile as 64 bit integers, this means they can only be read back in when the option --with-64bit-indices Many bris used. Many br

If running with __float128 precision the output is in __float128 unless one uses the -binary_read_double option Many br

The Buffer p should be read-write buffer, and not static data. Many brThis way, byte-swapping is done in-place, and then the buffer is Many brwritten to the file. Many br

This routine restores the original contents of the buffer, after Many brit is written to the file. This is done by byte-swapping in-place Many brthe second time. If the flag istemp is set to PETSC_TRUE, the second Many brbyte-swapping operation is not done, thus saving some computation, Many brbut the buffer is left corrupted. Many br

Because byte-swapping may be done on the values in data it cannot be declared const Many br

See Also

PetscBinaryRead(), PetscBinaryOpen(), PetscBinaryClose(), PetscViewerBinaryGetDescriptor(), PetscBinarySynchronizedWrite(),
PetscBinarySynchronizedRead(), PetscBinarySynchronizedSeek() Many br

Level:advanced
Location:
src/sys/fileio/sysio.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/vec/vec/examples/tutorials/ex6.c.html