[petsc-dev] SETERRQ in fortran

Smith, Barry F. bsmith at mcs.anl.gov
Thu Jan 4 15:16:56 CST 2018


  It's changed a bit.  It is better but you need to understand how the new one works, so take a few minutes to see how it works before converting.

  Use CHKERRA() for main Fortran problem and CHKERRQ() for subroutines.

  Also look at their definitions to see how the if () business is handled. 

  Barry


> On Jan 4, 2018, at 2:02 PM, Matthew Knepley <knepley at gmail.com> wrote:
> 
> On Thu, Jan 4, 2018 at 2:42 PM, Blaise A Bourdin <bourdin at lsu.edu> wrote:
> Hi,
> 
> Is SETERRQ still available in fortran? I notice that it is not used in any of the example, but the man page still mentions fortran. Using it in a fortran code leads to compiler errors.
> Am I doing something wrong?
> 
> I see it here:
> 
>   https://bitbucket.org/petsc/petsc/src/c925fbded0167f274f0216824a05edb59a5721f5/include/petsc/finclude/petscsys.h?at=master&fileviewer=file-view-default#petscsys.h-197
> 
> I think its complaining about the 'return;endif'
> 
>   Matt
> 
> MacBookGray:F90 $ cat TestSETERRQ.F90
> Program TestSETERRQ
> #include <petsc/finclude/petsc.h>
>    Use petsc
> 
>    Implicit NONE
>    PetscInt           :: ierr
>    Character(len=256) :: IOBuffer
> 
>    Call PetscInitialize(PETSC_NULL_CHARACTER, ierr);CHKERRA(ierr)
>    write(IOBuffer,'("This is a test ierr = ",I2,"\n")') ierr
>    SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_UNEXPECTED,IOBuffer)
>    call foo()
>    Call PetscFinalize(ierr)
> Contains
>     subroutine foo()
>        Character(len=256) :: IOBuffer
> 
>        write(IOBuffer,'("This is a test ierr = ",I2,"\n")') 42
>        SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_UNEXPECTED,IOBuffer)
>     end subroutine foo
> End Program TestSETERRQ
> 
> MacBookGray:F90 $ make -f makefile.TestSETERRQ TestSETERRQ
> mpif90 -c -Wall -ffree-line-length-0 -Wno-unused-dummy-argument -g    -I/opt/HPC/petsc-next/include -I/opt/HPC/petsc-next/Darwin-gcc7.2-g/include -I/opt/X11/include    -o TestSETERRQ.o TestSETERRQ.F90
> TestSETERRQ.F90:11:61:
> 
>     SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_UNEXPECTED,IOBuffer)
>                                                              1
> Error: Expecting END PROGRAM statement at (1)
> TestSETERRQ.F90:19:65:
> 
>         SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_UNEXPECTED,IOBuffer)
>                                                                  1
> Error: Expecting END SUBROUTINE statement at (1)
> make: [TestSETERRQ.o] Error 1 (ignored)
> 
> 
> 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
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 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
> 
> https://www.cse.buffalo.edu/~knepley/



More information about the petsc-dev mailing list