question concerning the automatic generation of fortran interfaces

Satish Balay balay at mcs.anl.gov
Fri Apr 18 01:08:00 CDT 2008


On Thu, 17 Apr 2008, Pascal Tremblay wrote:

> Dear PETSc Developer Team,
> 
> We (Pascal Tremblay and Nicolas Tardieu), are currently developing a multigrid
> preconditioner with PETSc in the context of a postdoc at Laval University. We
> want to use the PCMG skeleton to recycle what was already developed
> (especially the matrix triple product for CSR matrices).
> 
> However, the multigrid that we want to develop requires that extra information
> be passed to the multigrid preconditioner to properly compute the restriction
> (prolongation) matrices among other things. Since this information needs to be
> passed from a code that is written in Fortran 77 (the language that does not
> want to die!!!) we want to add a few c functions with interfaces that are
> compatible with PETSc, so we can pass a pointer to PC for example, and also
> automatically generate fortran interfaces like it is done in PETSc. For
> example, we have defined a function:
> 
> PetscErrorCode HMG_DLLEXPORT *HMGSetMeshElements*(PC iPC, PetscInt
> iElementType, PetscInt iNumberOfElements, PetscInt *iElementConnectivity,
> PetscInt * iElementIds)
> 
> Now I have looked at the PETSc documentation (manual.pdf, developer.pdf,
> website, forums) and also the makefile system and did not find any information
> on how to properly generate the fortran interfaces.

What you are looking for is manual for bfort. Its at:
http://www.cs.uiuc.edu/homes/wgropp/projects/software/sowing/bfort.pdf

The easiest thing to do is - just mimic PETSc code [for eg: the
formatted comment before MatMult() - its used for both manpage
generation - and bfort]

> I have installed bfort on my machine and with PETSc 2.1.6 I was able to
> regenerate the fortran wrappers with the command ???^??ake
> allfortranstubs???^?? but I have noticed that in the makefile for the version
> 2.3.3-p8 the command:
> 
> allfortranstubs: - at maint/generatefortranstubs.py ${BFORT}
> 
> calls generatefortranstubs.py, but I was not able to locate that python file
> (so I do not know exactly what it does).

scripts in maint are not part of the tarball. You should get the
source repository via mercurial for document generation work.

Its best to develop with petsc-dev

http://www-unix.mcs.anl.gov/petsc/petsc-as/developers/index.html 

If you really need petsc-2.3.3 - the repositories are available at 
http://petsc.cs.iit.edu/petsc/

[you'll need petsc-release-2.3.3 and BuildSystem-release-2.3.3]


> So finally my question: What is the appropriate manner in which a c function
> must be defined and processed using bfort and the PETSc tools to generate a
> fortran stub that is compatible with PETSc and can use PETSc types such as PC
> ((PETSc pointers to Mat and Vec usable, int and float of appropriate size
> etc.)? Note that I want to do this for a function that is compatible with
> PETSc, but is in a source tree that is outside of PETSc.


As long as the prototype of the routine is simple [with PETSc
datatypes, without chars - bfort should work. You can always look for
similar protypes in PETSc interface - and then check if it has auto
generated stub via bfort or not.

Satish

> 
> I know it is possible to generate a new preconditioner and use
> PCRegisterDynamic to register it dynamically, but we want to use PCMG to avoid
> reinventing the wheel.
> 
> Thank you for your much needed help,
> 
> N.B.: If you consider it appropriate it might be interesting to have something
> like this documented in one of the FAQ on your website for example.
> 
> 




More information about the petsc-dev mailing list