[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

question concerning the automatic generation of fortran interfaces



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.

I have installed bfort on my machine and with PETSc 2.1.6 I was able to regenerate the fortran wrappers with the command â^À^Ümake allfortranstubsâ^À^Ü, but I have noticed that in the makefile for the version 2.3.3-p8 the command:

allfortranstubs: -@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).

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.

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.

--
Pascal Tremblay, Ph.D.
Stagiaire postdoctoral
GIREF, DÃp. math. et stat., Università Laval
Pavillon Alexandre-Vachon, bureau VCH-1465
1045 avenue de la MÃdecine
QuÃbec (QuÃbec) Canada, G1V 0A6
TÃlÃphone: 418-656-2131x4340