Tom Clune writes:
> Phil,
>
> Thanks for the suggestion. I'll delve into the pointers that you
> provided, but after a cursory examination I think that this will not
> work.
>
> 1) The pyfortran page admits that it cannot handle "explicit"
> interfaces for fairly fundamental reasons. In fact, it is exactly
> these interfaces that C++ cannot handle either.
Right, you need to produce stubs to the Python C++ api using a
modified version of the pyfort preprocessor. This is just your
suggestion 3), with the target being the Python class hierarchy
instead of the C++ class hierarchy (and for another take on this
general approach, see
@Article{gray99shadow,
author = {M. C. Gray and R. M. Roberts and T. M. Evans},
title = {Shadow-object interface between Fortran95 and C++},
journal = {Comp. in Sci. and Engineer.},
year = 1999,
volume = 1,
number = 2,
pages = {63-70},
annote = {http://computer.org}
}
There's also a nice example of doing this kind of thing using SWIG:
Lightweight Computational Steering of Very Large Scale Molecular
Dynamics Simulations by David M. Beazley and Peter S. Lomdahl
(http://rustler.cs.uchicago.edu/~pxl/papers/sc96/INDEX.HTM)
>
> 2) The following is not a deal-breaker, but it raises my skepticism
> up a few notches. From the Numerical Python page:
>
> "If x and y are Numerical Python arrays, then the speed of the
> operation x + y is close to the speed of doing it in C if the
> arrays are big enough."
>
> This indicates rather extreme naivete with regards to optimization.
> If all that one is doing is adding two arrays, the best the
> compiler can do is keep memory bandwidth saturated.
All this is supposed to mean is that Python overloads "+" to call a C
function, with very little overhead imposed by the interpretor. Our
experience has been that loop speed is not a problem. What is a
problem is the generation of temporaries for complicated expressions
(a problem F90 shares).
As an aside: does anyone know whether Fortran 2000 has found a way
around this issue without using template metaprogramming?
Regards, Phil
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|