[petsc-users] Fortran interface of some petsc routines seem to be missing

Smith, Barry F. bsmith at mcs.anl.gov
Tue Nov 27 15:49:49 CST 2018


    PETSc uses the Sowing packages bfort tool for automatically generating "Fortran stub functions" and interface definitions.  There are certain C functions that bfort cannot handling including (at least)

1) functions with character string arguments
2) functions with function pointer arguments (such as SNESSetFunction())
3) functions that support polymorphism between array and non-array arguments (for example VecSetValues() where the ix and y arguments can be either scalars or arrays).
4) functions that can take a NULL argument. 

    Functions that bfort can automatically generate the stub and the interface definition are marked with /*@ at the beginning of the comment above the function (see for example src/ksp/ksp/interface/itcreate.c KSPCreate()). If bfort cannot work then the comment begins with /*@C (see for example src/sys/objects/pinit.c PetscInitiialize()).

    It is our intention to provide manual Fortran stubs and interface for functions that bfort cannot handle. 

    As you note we do not currently provide all the interface definitions, many even basic ones are missing. This is because we wrote the manual stub functions many, many years ago when we wrote the C functions but only in the past couple of years have we been providing interfaces and no one went back and added all the required manual interface definitions.

   I did not know about the gfortran option -Wimplicit-interface; this is a great tool for finding missing interfaces. Thanks for letting us know about it.

   The manually generated stub functions are stored in files in the subdirectories ftn-custom from where the C function is defined. The filename is the C file name prepended with a Z and appended with an f. For example snes.c   becomes ftn-custom/zsnesf.c   The manually generated interface definitions should go into the file src/XXX/f90-mod/petscYYY.h90 for example the interfaces for VecSetValues are in src/vec/f90-mod/petscvec.h90   

   If you are ambitious and know about pull requests we'd be very happy to accept a pull request that provided the missing manual interface definitions. If you are less ambitious you could send us the interface definitions that you create and we'll add them ourselves to the PETSc repository. Or eventually we'll provide more and more of the interface definitions as time permits.


   Barry





   

> On Nov 27, 2018, at 9:28 AM, Natacha BEREUX via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> Hello, 
> I work on a Fortran software that uses PETSc for linear solvers. Therefore, we have a PETSc interface to convert our matrices to PETSc Mat. 
> I have noticed several compiler warnings ( I use gfortran with -Wimplicit-interface)  during compilation. The warnings point out that some (but not all) fortran interfaces are missing.  
> 
> The behaviour is the same when I compile a PETSC example. Below is src/vec/vec/examples/tutorials/ex9f.F compiled with gfortran.  
> 
> mpif90 -c -fPIC -Wall -ffree-line-length-0 -Wno-unused-dummy-argument -Wimplicit-interface  -g -O    -I/home/H03755/Librairies/petsc-3.10.1/include -I/home/H03755/Librairies/petsc-3.10.1/linux-opt-mumps-ml-hypre-superlu/include -I/home/H03755/dev/codeaster-prerequisites/v14/prerequisites/Mumps-512_consortium_aster3/MPI/include -I/home/H03755/local/petsc/petsc-3.10.1/include    -o ex9f.o ex9f.F90
> ex9f.F90:34.53:
> 
>       call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
>                                                      1
> Warning: Procedure 'petscinitialize' called with an implicit interface at (1)
> ex9f.F90:42.91:
> 
>       if (size .ne. 2) then; call PetscError(PETSC_COMM_WORLD,1,0,'Requires 2 processors'); call MPIU_Abort(PETSC_COMM_WORLD,1); endif
>                                                                                            1
> Warning: Procedure 'petscerror' called with an implicit interface at (1)
> ex9f.F90:42.128:
> 
>       if (size .ne. 2) then; call PetscError(PETSC_COMM_WORLD,1,0,'Requires 2 processors'); call MPIU_Abort(PETSC_COMM_WORLD,1); endif
>                                                                                                                                 1
> Warning: Procedure 'mpiu_abort' called with an implicit interface at (1)
> ex9f.F90:81.56:
> 
>      &        PETSC_DECIDE,nghost,ifrom,tarray,gxs,ierr)
>                                                         1
> Warning: Procedure 'veccreateghostwitharray' called with an implicit interface at (1)
> ex9f.F90:99.53:
> 
>        call VecGetOwnershipRange(gx,rstart,rend,ierr)
>                                                      1
> Warning: Procedure 'vecgetownershiprange' called with an implicit interface at (1)
> ex9f.F90:115.93:
> 
>        call PetscViewerGetSubViewer(PETSC_VIEWER_STDOUT_WORLD,PETSC_COMM_SELF,subviewer,ierr)
>                                                                                              1
> Warning: Procedure 'petscviewergetsubviewer' called with an implicit interface at (1)
> ex9f.F90:117.97:
> 
>        call PetscViewerRestoreSubViewer(PETSC_VIEWER_STDOUT_WORLD,PETSC_COMM_SELF,subviewer,ierr)
>                                                                                                  1
> Warning: Procedure 'petscviewerrestoresubviewer' called with an implicit interface at (1)
> ex9f.F90:121.31:
> 
>        call PetscFinalize(ierr)
>                                1
> Warning: Procedure 'petscfinalize' called with an implicit interface at (1)
> 
> 
> Why does the compiler complain  ? 
> Did I miss something when I compiled PETSc library ? Is there a way to properly generate all the Fortran interfaces in the compiled library ?
> Or is it normal that PETSc only generates some interfaces but not all ? 
> In this case, is there a way to know which interfaces are explicitly and automatically  defined  in PETSc library ?  So that I can provide manually the missing ones in my code ? 
> 
> Thanks a lot for your help !
> Best regards, 
> Natacha 
>  
> 
> 
> 



More information about the petsc-users mailing list