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

# VecLoad

Loads a vector that has been stored in binary or HDF5 format with VecView().

### Synopsis

    #include "petscvec.h"
    PetscErrorCode  VecLoad(Vec newvec, PetscViewer viewer)

Collective on PetscViewer Many br

### Input Parameters

| newvec | - the newly loaded vector, this needs to have been created with VecCreate() or Many brsome related function before a call to VecLoad(). Many br
| viewer | - binary file viewer, obtained from PetscViewerBinaryOpen() or Many brHDF5 file viewer, obtained from PetscViewerHDF5Open() Many br

Many br

### Notes

Defaults to the standard Seq or MPI Vec, if you want some other type of Vec call VecSetFromOptions() Many brbefore calling this. Many br

The input file must contain the full global vector, as Many brwritten by the routine VecView(). Many br

If the type or size of newvec is not set before a call to VecLoad, PETSc Many brsets the type and the local and global sizes. If type and/or Many brsizes are already set, then the same are used. Many br

If using binary and the blocksize of the vector is greater than one then you must provide a unique prefix to Many brthe vector with PetscObjectSetOptionsPrefix((PetscObject)vec,"uniqueprefix"); BEFORE calling VecView() on the Many brvector to be stored and then set that same unique prefix on the vector that you pass to VecLoad(). The blocksize Many brinformation is stored in an ASCII file with the same name as the binary file plus a ".info" appended to the Many brfilename. If you copy the binary file, make sure you copy the associated .info file with it. Many br

If using HDF5, you must assign the Vec the same name as was used in the Vec Many brthat was stored in the file using PetscObjectSetName(). Otherwise you will Many brget the error message: "Cannot H5DOpen2() with Vec name NAMEOFOBJECT" Many br

### Notes for advanced users

Most users should not need to know the details of the binary storage Many brformat, since VecLoad() and VecView() completely hide these details. Many brBut for anyone who's interested, the standard binary matrix storage Many brformat is Many br

         int    VEC_FILE_CLASSID
         int    number of rows
         PetscScalar *values of all entries

Many br

In addition, PETSc automatically does the byte swapping for Many brmachines that store the bytes reversed, e.g. DEC alpha, freebsd, Many brlinux, Windows and the paragon; thus if you write your own binary Many brread/write routines you have to swap the bytes; see PetscBinaryRead() Many brand PetscBinaryWrite() to see how this may be done. Many br

### See Also

PetscViewerBinaryOpen(), VecView(), MatLoad(), VecLoad()

Level:intermediate
Location:src/vec/vec/interface/vector.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/vec/vec/examples/tutorials/ex5.c.html
src/vec/vec/examples/tutorials/ex6.c.html
src/vec/vec/examples/tutorials/ex10.c.html
src/vec/vec/examples/tutorials/ex19.c.html
src/vec/vec/examples/tutorials/ex42.c.html
src/vec/vec/examples/tutorials/ex42a.c.html
src/mat/examples/tutorials/ex12.c.html
src/dm/examples/tutorials/ex9.c.html
src/dm/examples/tutorials/ex10.c.html
src/dm/examples/tutorials/ex15.c.html
src/ksp/ksp/examples/tutorials/ex10.c.html