Hi, > 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? I would be in favor of not deleting people's files unless they explicitly ask for it ;) defaulting to append may be the best way, if it is implemented
> To open in READ mode, just do this: > > PETSc.Viewer().createHDF5(inputfile, mode=PETSc.Viewer.Mode.READ, > comm= PETSc.COMM_WORLD) much nicer, thanks, Blaise -- Department of Mathematics and Center for Computation & Technology Louisiana State University, Baton Rouge, LA 70803, USA Tel. +1 (225) 578 1612, Fax +1 (225) 578 4276 http://www.math.lsu.edu/~bourdin
