[petsc-dev] PetscExceptionTry1

Barry Smith bsmith at mcs.anl.gov
Mon Feb 14 13:51:41 CST 2011


On Feb 14, 2011, at 1:43 PM, Matthew Knepley wrote:

> On Mon, Feb 14, 2011 at 1:40 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
> On Feb 14, 2011, at 1:38 PM, Matthew Knepley wrote:
> 
> > Do we have a replacement for this?
> 
>  Nope.
> 
> > I was using it, but it seems to be broken
> > and now my code spits out annoying error messages to the screen.
> 
>  Handle the "exception" with "regular" code that does not call the SETERRQ() but instead "handles the problem" itself.
> 
> This code
> 
>   for(i = 0; i < 10000; ++i) {
>     std::ostringstream trial;
>     FILE              *fp;
> 
>     trial << "dft_" << std::setw(5) << std::setfill('0') << i << ".py";
if (rank) {
  ierr = PetscTestFile(trial.str().c_str(), "r", &exists);CHKERRQ(ierr);
 if (!exists) break;
> err = PetscFOpen(PETSC_COMM_WORLD, trial.str().c_str(), "r", &fp);
> whatever
>     ierr = PetscFClose(PETSC_COMM_WORLD, fp);CHKERRQ(ierr);
}
  
  Looks like PetscTestFile() should be updated to take a comm and have a manual page written for it.

   Barry

> 
>     //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
> 
> [0]PETSC ERROR: --------------------- Error Message ------------------------------------
> [0]PETSC ERROR: Unable to open file!
> [0]PETSC ERROR: Unable to open file dft_00001.py
> !
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Development HG revision: f77bf280bb316b4e138b482394ca6d06ce3b63cd  HG Date: Mon Jan 31 21:25:29 2011 -0600
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [0]PETSC ERROR: See docs/index.html for manual pages.
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: /PETSc3/biology/dft-rfd/bin/arch-complex-fftw-debug/dft-fft-3d on a arch-comp named cohn0636n.rush.edu by knepley Mon Feb 14 13:25:35 2011
> [0]PETSC ERROR: Libraries linked from /PETSc3/petsc/petsc-dev/arch-complex-fftw-debug/lib
> [0]PETSC ERROR: Configure run at Thu Feb  3 11:53:58 2011
> [0]PETSC ERROR: Configure options --PETSC_ARCH=arch-complex-fftw-debug --with-shared-libearies --with-dynamic-loading --download-mpich --download-fftw --with-clanguage=cxx --with-scalar-type=complex
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: PetscFOpen() line 63 in src/sys/fileio/mpiuopen.c
> 
>    Matt
>  
> 
>   Barry
> 
> >
> >    Matt
> >
> > --
> > What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
> > -- Norbert Wiener
> 
> 
> 
> 
> -- 
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
> -- Norbert Wiener




More information about the petsc-dev mailing list