FAQ: How do I wrap FORTRAN source code into the framework
From DANSE
I'm not a FORTRAN expert, but I believe this can be broken down into a series of steps, most of which I know how to do. If there's consensus that this is a sound approach, then I'm sure others can supply the missing pieces. For the moment, I'm going to restrict discussion to f77.
Binding f77 code into the framework consists of the following steps:
- bind the f77 code into C
- bind the C code into Python
- write a C wrapper function that can be called from Python
- dress that wrapper function with appropriate Python class/function
- wrap the Python code into pyre components
Wrapping python code into pyre components is undergoing extensive discussion on the Monday conference calls, and we will have a comprehensive example available soon (the nintegrate package). Binding C functions into Python has been addressed in the tutorial (PUT LINK HERE); if you have questions, please contact Tim, Jiao, or Mike, consult the FAQ, etc. So all we really need to understand is how to call f77 from C. This is, for the most part, very straightforward. One simply needs to understand how to map C types to fortran types.
Calling fortran from C
Basically, one calls the fortran subroutine just like one calls a C function, except that FORTRAN variables are passed by reference. So suppose you have a F77 routine that takes a REAL*8. In C, you would pass the address of a 64 bit floating point number (usually, this is a double).
...to be continued...(or anyone else, jump in)... --Tim 09:14, 12 Jun 2005 (PDT)
