# PetscViewerBinaryOpen

Opens a file for binary input/output.

### Synopsis

    #include "petsc.h"
    PetscErrorCode PETSC_DLLEXPORT PetscViewerBinaryOpen(MPI_Comm comm,const char name[],PetscViewerFileType type,PetscViewer *binv)

Collective on MPI_Comm

### Input Parameters

| comm | - MPI communicator
| name | - name of file
| type | - type of file

       PETSC_FILE_CREATE - create new file for binary output

       PETSC_FILE_RDONLY - open existing file for binary input

       PETSC_FILE_WRONLY - open existing file for binary output

### Output Parameter

binv -PetscViewer for binary input/output to use with the specified file

### Note

This PetscViewer should be destroyed with PetscViewerDestroy().

For reading files, the filename may begin with ftp:// or http:// and/or end with .gz; in this case file is brought over and uncompressed.

For creating files, if the file name ends with .gz it is automatically compressed when closed.

For writing files it only opens the file on processor 0 in the communicator. For readable files it opens the file on all nodes that have the file. If node 0 does not have the file it generates an error even if other nodes do have the file.

### See Also

PetscViewerASCIIOpen(), PetscViewerSetFormat(), PetscViewerDestroy(),
VecView(), MatView(), VecLoad(), MatLoad(), PetscViewerBinaryGetDescriptor(), PetscViewerBinaryGetInfoPointer(), PetscViewerFileType, PetscViewer, PetscBinaryViewerRead()

Level:beginner
Location:src/sys/src/viewer/impls/binary/binv.c
Index of all Viewer routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/sys/examples/tutorials/ex5.c.html
src/vec/examples/tutorials/ex5.c.html
src/vec/examples/tutorials/ex6.c.html
src/mat/examples/tutorials/ex1.c.html
src/mat/examples/tutorials/ex4.c.html
src/mat/examples/tutorials/ex5.c.html
src/ksp/examples/tutorials/ex10.c.html
src/ksp/examples/tutorials/ex27.c.html
src/snes/examples/tutorials/ex26.c.html
src/snes/examples/tutorials/ex29.c.html
src/snes/examples/tutorials/ex30.c.html