[petsc-users] PetscCall( ) in fortran

Barry Smith bsmith at petsc.dev
Thu Aug 17 18:50:46 CDT 2023



> On Aug 17, 2023, at 7:44 PM, Sanjay Govindjee <s_g at berkeley.edu> wrote:
> 
> Two questions about the PetscCall( ) etc. functionality in fortran:
> 
> (1) To use this functionality, is it required to use a .F90 naming convention? or should I be able to use .F?

   This likely depends on the compiler. 
> 
> (2) Is it permitted to use line continuation within these calls? For example something like
> 
>       PetscCallMPIA(MPI_Allreduce(localval,globalsum,1,&
>         MPIU_REAL,MPIU_SUM, PETSC_COMM_WORLD,ierr))
> 
> or is it required to just have an extra long line? or is there an alternate syntax for continuation in this case?

   Because PetscCallXXX() is a macro, it "breaks" if a continuation is used, so yes, you will sometimes need long lines. Most Fortran compilers have an option to allow infinitely long lines. 

   Note that you can still use CHKERRQ() either all the time or in situations where you "need" a continuation character.

  Barry


> 
> -sanjay
> 



More information about the petsc-users mailing list