[petsc-users] PetscCall( ) in fortran

Satish Balay balay at mcs.anl.gov
Fri Aug 18 08:59:37 CDT 2023


I think gfortran defaults to fixed form for .F and free-form for .F90

This can be changed with FFLAGS=-ffree-form - but yeah - switching the suffix might be more suitable..

In addition - PETSc configure attempts to add in "-ffree-line-length-none -ffree-line-length-0" options - so that extra long source lines can be used [with the default PETSc makefiles].

Satish


On Thu, 17 Aug 2023, Sanjay Govindjee wrote:

> Thanks.
> 
> For what it is worth in regards to question (1), GNU Fortran (Homebrew GCC
> 11.3.0_2) 11.3.0 seems to need .F90 (as opposed to just .F).
> 
> -sanjay
> 
> 
> On 8/17/23 4:50 PM, Barry Smith wrote:
> >
> >> 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