PetscBinaryWrite

Writes to a binary file.

Synopsis

#include "petsc.h"    
int PetscBinaryWrite(int fd,void *p,int n,PetscDataType type,int istemp)
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)
istemp - 0 if buffer data should be preserved, 1 otherwise.

Notes

PetscBinaryWrite() uses byte swapping to work on all machines. Integers are stored on the file as 32 long, regardless of whether they are stored in the machine as 32 or 64, this means the same binary file may be read on any machine.

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. If the flag istemp is set to 1, the second byte-swapping operation is not done, thus saving some computation, but the buffer corrupted is corrupted.

See Also

PetscBinaryRead(), PetscBinaryOpen(), PetscBinaryClose()

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

Examples

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