[petsc-dev] CHKERRQ vs PetscCall for Fortran? Which is the future?

Jacob Faibussowitsch jacob.fai at gmail.com
Tue Apr 26 20:27:22 CDT 2022


> PetscCall in C doesn’t actually “call” the function that is in its arguments, but rather “checks” the called function’s return 

The most logical form would have been `PetscCheck()` but we unfortunately we had just recently added it as a replacement for

```
if (error) SETERRQ()
``` 

So the idea instead was to have a `PetscSafeCall()` but with less typing. It also fit with the previous `PetscStackCall()` family. You can find the naming discussion here https://gitlab.com/petsc/petsc/-/merge_requests/4889#note_854556084

Best regards,

Jacob Faibussowitsch
(Jacob Fai - booss - oh - vitch)

> On Apr 26, 2022, at 20:18, Boyce Griffith <boyceg at gmail.com> wrote:
> 
> 
> 
>> On Apr 26, 2022, at 8:12 PM, Barry Smith <bsmith at petsc.dev <mailto:bsmith at petsc.dev>> wrote:
>> 
>> I didn't like PetscCall(ierr) in Fortran because it is strange, even freakish. PetscCall(AFunction(args)) makes sense in C but IMHO "call AFunction(args,ierr); PetscCall(ierr)" looks weird, what are you calling? Nothing. I'd like to keep CHKERRQ(ierr) in Fortran and not support PetscCall(ierr) in Fortran. 
> 
> I have to admit that I don’t really understand the C usage either, since unless I am misreading the code, PetscCall in C doesn’t actually “call” the function that is in its arguments, but rather “checks” the called function’s return value.
> 
> — Boyce

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20220426/8eadd52d/attachment.html>


More information about the petsc-dev mailing list