[petsc-dev] [petsc4py] PETSc.Viewer().createHDF5 wipes out existing files

Dmitry Karpeev karpeev at mcs.anl.gov
Thu Sep 9 17:24:11 CDT 2010


It seems to me that a nondestructive default would be better.
I guess there is an expectation that users open viewers to write to
more than to read from,
but I think we still don't want to wipe out their files without an
explicit authorization.
Dmitry.

On Thu, Sep 9, 2010 at 4:24 PM, Lisandro Dalcin <dalcinl at gmail.com> wrote:
> On 9 September 2010 17:40, Blaise Bourdin <bourdin at math.lsu.edu> wrote:
>> Hi,
>>
>> I am trying to do HDF5 IO in petsc4py. I noticed that when I create a viewer using
>>  PETSc.Viewer().createHDF5(inputfile,comm= PETSc.COMM_WORLD)
>> the file "outputfile" is wiped out and replaced with a empty hdf5 container, which is bad since I am trying to read forrm it...
>>
>> Unsurprisingly, I have no problems using the longer approach:
>>  h5in = PETSc.Viewer().create(PETSc.COMM_WORLD)
>>  h5in.setType(PETSc.Viewer.Type.HDF5)
>>  h5in.setFileMode(PETSc.Viewer.Mode.READ)
>>  h5in.setFileName(inputfile)
>>
>> Is this expected?
>>
>
> Yes, it is expected. These create() methods default to mode=WRITE.
> What you and others think about this?
>
> To open in READ mode, just do this:
>
> PETSc.Viewer().createHDF5(inputfile, mode=PETSc.Viewer.Mode.READ,
> comm= PETSc.COMM_WORLD)
>
>
>
>
> --
> Lisandro Dalcin
> ---------------
> CIMEC (INTEC/CONICET-UNL)
> Predio CONICET-Santa Fe
> Colectora RN 168 Km 472, Paraje El Pozo
> Tel: +54-342-4511594 (ext 1011)
> Tel/Fax: +54-342-4511169
>



More information about the petsc-dev mailing list