[petsc-dev] CHKERRQ vs PetscCall for Fortran? Which is the future?
Barry Smith
bsmith at petsc.dev
Tue Apr 26 19:12:02 CDT 2022
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.
Now depending on how the Fortran preprocessor handles args could we have PetscCall(AFunction(args,ierr)) in Fortran that turns into "call AFunction(args,ierr); CHKERRQ(ierr)"? It is perhaps weird Fortran but mimics and is largely consistent with C. We could also keep CHKERRQ() permanently for Fortran purists who are freaked out by PetscCall(AFunction(args,ierr)) in Fortran
Barry
So long as ierr is always spelled as ierr probably
#define PetscCall(A) call A; CHKERR(ierr)
will probably work.
> On Apr 26, 2022, at 7:02 PM, Satish Balay via petsc-dev <petsc-dev at mcs.anl.gov> wrote:
>
> Hm we reverted all fortran examples to use CHKERRQ(). [from PetscCall] so presumably CHKERRQ() is still the preferred interface from fortran?
>
> Satish
>
> On Tue, 26 Apr 2022, Jacob Faibussowitsch wrote:
>
>> Hi Glenn,
>>
>> `PetscCall()` is the future, apologies for the confusion.
>>
>> `CHKERRQ()` was mistakenly deleted from the fortran include files but exists for backwards-compatibility only.
>>
>> Unlike “normal” changes we opted not to formally deprecate `CHKERRQ()` and friends (complete with compiler warnings) since they are so widely used.
>>
>> Best regards,
>>
>> Jacob Faibussowitsch
>> (Jacob Fai - booss - oh - vitch)
>>
>>> On Apr 26, 2022, at 17:36, Hammond, Glenn E via petsc-dev <petsc-dev at mcs.anl.gov> wrote:
>>>
>>> PETSc,
>>>
>>> I see that CHKERRQ is back in the Fortran interface after 3.17.1. Will CHKERRQ be removed in the future? I just wrote a script to refactor PFLOTRAN [CHKERRQ() -> PetscCall()], and I want to know which direction to head before asking everything to check in all their dev branches. If CHKERRQ() is available with Fortran for the future, I will abandon the script and leave the devs alone.
>>>
>>> Thanks,
>>>
>>> Glenn
>>
More information about the petsc-dev
mailing list