[petsc-users] Question on PetscViewerFileSetMode

Barry Smith bsmith at petsc.dev
Tue Aug 30 09:21:58 CDT 2022


   You should only use PetscViewerFileSetMode to APPEND  when you first create the viewer. You would only set it to APPEND if you destroy and recreate the viewer for each time-step.

   The append tells the viewer that when it opens the file it should move its pointer to the end of the file (so that the next writes append instead of replacing the old material). But when the file is already open and written to the pointer always points to the end of the file so there is no reason to append.

   I guess in the past we had less error checking so that your use did not trigger an error condition; but also in the past setting to append later did not break anything so it worked fine for you. Just remove the unneeded extra call to PetscViewerFileSetMode

  Barry


> On Aug 30, 2022, at 2:03 AM, Yuyun Yang <yyang85 at alumni.stanford.edu> wrote:
> 
> Hello team,
> 
> I recently updated by PETSc version and this error emerged:
> "Cannot change mode to APPEND after setup"
> 
> I used to  use PetscViewerFileSetMode to set the mode as WRITE when I first initiate the file, and for following time steps I set it to APPEND to open the existing file and append data. Has the functionality changed?
> 
> Thanks!
> 
> Best regards,
> Yuyun



More information about the petsc-users mailing list