On Feb 14, 2011, at 1:48 PM, Jed Brown wrote:
> On Mon, Feb 14, 2011 at 20:43, Matthew Knepley <knepley at gmail.com> wrote:
> This code
>
> for(i = 0; i < 10000; ++i) {
> std::ostringstream trial;
> FILE *fp;
>
> trial << "dft_" << std::setw(5) << std::setfill('0') << i << ".py";
> //ierr = PetscExceptionTry1(PetscFOpen(PETSC_COMM_WORLD,
> trial.str().c_str(), "r", &fp), PETSC_ERR_FILE_OPEN);
> ierr = PetscFOpen(PETSC_COMM_WORLD, trial.str().c_str(), "r", &fp);
> if (ierr == PETSC_ERR_FILE_OPEN) break;
> ierr = PetscFClose(PETSC_COMM_WORLD, fp);CHKERRQ(ierr);
> }
>
> produces the following printout
>
> You need to PetscPushErrorHandler(PetscReturnErrorHandler,0);
You could do that. But I think it is better to not generate an error at all
by first checking if you can actually open the file before trying to open it.
I found the exception stuff I put in PETSc was too clunky for almost anyone
to use and feel it is better to reserve the PETSc error system for truly deadly
unrecoverable errors.
Barry