PetscViewerBinaryWrite

Matthew Knepley knepley at gmail.com
Wed Apr 18 14:00:55 CDT 2007


On 4/18/07, Randall Mackie <randy at geosystem.us> wrote:
> In my fortran program, I save the results of calculations in a binary file
> for later use, like this:
>
>            IF (rank == 0) THEN
>              irec = irec + 1
>              write(7,rec=irec) hsavx(:,ipol)
>              irec = irec + 1
>              write(7,rec=irec) hsavy(:,ipol)
>              irec = irec + 1
>              write(7,rec=irec) hsavz(:,ipol)
>            END IF
>
> And then read them back later in a similar fashion.
>
>
> Is it possible to replace this with PetscViewerBinaryWrite?

Should be.

> There is a flag in this call called istemp, which specifies if the
> data can be overwritten. I believe if you set this to false, then
> with each call you would simply append the vector to the file?

Actually, the flag is a little more obscure than that. You should just
not set it. You would open a ViewerBinary and then use VecView()
I think.

> My question is when you go back to re-read in these vectors, how
> does PetscViewerBinaryRead know where to start? In other words,
> I don't see a way to specify to start at the beginning, or rewind
> the file, or maybe these Fortran concepts are not valid?

I am not sure I understand this part. However, I think what you want
is to close the inital viewer when you are done writing. When you want
to read in, you open a new viewer and use VecLoad(). If you need something
fancier, there are functions for changing the file offset, but that demands
knowedge of the underlying format.

   Matt

> Thanks for any suggestions.
>
> Randy
>
> --
> Randall Mackie
> GSY-USA, Inc.
> PMB# 643
> 2261 Market St.,
> San Francisco, CA 94114-1600
> Tel (415) 469-8649
> Fax (415) 469-5044
>
> California Registered Geophysicist
> License No. GP 1034
>
>


-- 
The government saving money is like me spilling beer. It happens, but
never on purpose.




More information about the petsc-users mailing list