<div dir="ltr"><div dir="ltr">Dear Barry <br>thank you very much for this very detailed answer. It's perfectly clear now.<br>I'll start writing the missing interfaces<br>I need to wait until I have made progress on writing the interfaces before deciding whether to create a pull request or send part of the interface definitions.<br>In any case, thank you again for your help,<br></div><div>Best regards<br></div><div>Natacha <br></div><div dir="ltr"><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 27, 2018 at 10:49 PM Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
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)<br>
<br>
1) functions with character string arguments<br>
2) functions with function pointer arguments (such as SNESSetFunction())<br>
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).<br>
4) functions that can take a NULL argument. <br>
<br>
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()).<br>
<br>
It is our intention to provide manual Fortran stubs and interface for functions that bfort cannot handle. <br>
<br>
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.<br>
<br>
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.<br>
<br>
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 <br>
<br>
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.<br>
<br>
<br>
Barry<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
> On Nov 27, 2018, at 9:28 AM, Natacha BEREUX via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
> <br>
> Hello, <br>
> 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. <br>
> 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. <br>
> <br>
> The behaviour is the same when I compile a PETSC example. Below is src/vec/vec/examples/tutorials/ex9f.F compiled with gfortran. <br>
> <br>
> 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<br>
> ex9f.F90:34.53:<br>
> <br>
> call PetscInitialize(PETSC_NULL_CHARACTER,ierr)<br>
> 1<br>
> Warning: Procedure 'petscinitialize' called with an implicit interface at (1)<br>
> ex9f.F90:42.91:<br>
> <br>
> if (size .ne. 2) then; call PetscError(PETSC_COMM_WORLD,1,0,'Requires 2 processors'); call MPIU_Abort(PETSC_COMM_WORLD,1); endif<br>
> 1<br>
> Warning: Procedure 'petscerror' called with an implicit interface at (1)<br>
> ex9f.F90:42.128:<br>
> <br>
> if (size .ne. 2) then; call PetscError(PETSC_COMM_WORLD,1,0,'Requires 2 processors'); call MPIU_Abort(PETSC_COMM_WORLD,1); endif<br>
> 1<br>
> Warning: Procedure 'mpiu_abort' called with an implicit interface at (1)<br>
> ex9f.F90:81.56:<br>
> <br>
> & PETSC_DECIDE,nghost,ifrom,tarray,gxs,ierr)<br>
> 1<br>
> Warning: Procedure 'veccreateghostwitharray' called with an implicit interface at (1)<br>
> ex9f.F90:99.53:<br>
> <br>
> call VecGetOwnershipRange(gx,rstart,rend,ierr)<br>
> 1<br>
> Warning: Procedure 'vecgetownershiprange' called with an implicit interface at (1)<br>
> ex9f.F90:115.93:<br>
> <br>
> call PetscViewerGetSubViewer(PETSC_VIEWER_STDOUT_WORLD,PETSC_COMM_SELF,subviewer,ierr)<br>
> 1<br>
> Warning: Procedure 'petscviewergetsubviewer' called with an implicit interface at (1)<br>
> ex9f.F90:117.97:<br>
> <br>
> call PetscViewerRestoreSubViewer(PETSC_VIEWER_STDOUT_WORLD,PETSC_COMM_SELF,subviewer,ierr)<br>
> 1<br>
> Warning: Procedure 'petscviewerrestoresubviewer' called with an implicit interface at (1)<br>
> ex9f.F90:121.31:<br>
> <br>
> call PetscFinalize(ierr)<br>
> 1<br>
> Warning: Procedure 'petscfinalize' called with an implicit interface at (1)<br>
> <br>
> <br>
> Why does the compiler complain ? <br>
> Did I miss something when I compiled PETSc library ? Is there a way to properly generate all the Fortran interfaces in the compiled library ?<br>
> Or is it normal that PETSc only generates some interfaces but not all ? <br>
> 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 ? <br>
> <br>
> Thanks a lot for your help !<br>
> Best regards, <br>
> Natacha <br>
> <br>
> <br>
> <br>
> <br>
<br>
</blockquote></div>