[petsc-dev] SETERRQ in fortran

Blaise A Bourdin bourdin at lsu.edu
Thu Jan 4 17:10:06 CST 2018



> On Jan 4, 2018, at 3:16 PM, Smith, Barry F. <bsmith at mcs.anl.gov> wrote:
> 
> 
>  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.
Got it.
An example or a link to the fortran macro definition from the man page would be nice 
I am confused about the rationale for putting the endif in the macro, though.
Beside not having unmatched if / end if in my code, in a select case construct, I have to write something as ugly as

select case (i)
	case(1) 
		!do something
	case(2)
		!do something else
	case default
		if (0 == 0) then
			SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANG,”invalid value”)
end select

Am I missing something again?

Blaise


> 
>  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://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbitbucket.org%2Fpetsc%2Fpetsc%2Fsrc%2Fc925fbded0167f274f0216824a05edb59a5721f5%2Finclude%2Fpetsc%2Ffinclude%2Fpetscsys.h%3Fat%3Dmaster%26fileviewer%3Dfile-view-default%23petscsys.h-197&data=02%7C01%7Cbourdin%40lsu.edu%7C9e126b88c4de4bb5b1c108d553b87d8a%7C2d4dad3f50ae47d983a09ae2b1f466f8%7C0%7C0%7C636506974199979974&sdata=R6xnRLTzelnxPz39tkA0warCI%2BUFt%2FAnM8haZbjANQA%3D&reserved=0
>> 
>> 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 https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.math.lsu.edu%2F~bourdin&data=02%7C01%7Cbourdin%40lsu.edu%7C9e126b88c4de4bb5b1c108d553b87d8a%7C2d4dad3f50ae47d983a09ae2b1f466f8%7C0%7C0%7C636506974199979974&sdata=DM5ZtUYkEBxwU%2FVS7eHC8dF%2Fw2w9aSbP9l8YvL3Nj6o%3D&reserved=0
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> -- 
>> 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://na01.safelinks.protection.outlook.com/?url=https:%2F%2Fwww.cse.buffalo.edu%2F~knepley%2F&data=02%7C01%7Cbourdin%40lsu.edu%7C9e126b88c4de4bb5b1c108d553b87d8a%7C2d4dad3f50ae47d983a09ae2b1f466f8%7C0%7C0%7C636506974199979974&sdata=99K5TljrSNkF7MGImBkWQTjXCUt%2BdwB8XAHB%2FQztQZY%3D&reserved=0
> 

-- 
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









More information about the petsc-dev mailing list