[Numpy-discussion] Help using numpy.distutils.fcompiler for my GSoC project
Kurt Smith
kwmsmith at gmail.com
Mon Jun 22 22:53:15 EDT 2009
Hello,
I'm working under the able mentoring of Dag Sverre Seljebotn to
implement a GSoC project informally known as 'f2cy'. From the 10,000
meter view, f2cy will (1) wrap fortran 77/90/95 code into a python
module (reproducing f2py in this regard) with full support for
assumed-shape fortran arrays (beyond f2py, if I'm not mistaken); and
(2) will wrap the same fortran code in *cython* cdef functions that
can be manipulated at the cython level with no interaction with the
python API -- yielding close to the metal speed, even for small
functions.
We're making use of the new ISO_C_BINDING intrinsic module implemented
in most every extant Fortran 95 compiler (including gfortran) to make
the resulting code very portable. This introduces a small wrinkle to
the compilation of the python/cython module, and that's the content of
my question.
Basically, f2cy generates a 'genconfig.f95' fortran source file that,
when compiled and run, creates another fortran source file
'config.f95' and a C header file 'config.h'. config.f95 defines a
module that contains the necessary mappings between the ISO_C_BINDING
kind-type-parameters (ktps) and the ktps used in the rest of the
generated source code. The genconfig.f95 file needs to be compiled
and run before the python module can be compiled, since the python
module depends on the 'config.f95' file.
Once config.f95 exists, it is easy to make the python module. The
trick is in generating the 'config.f95' file in a portable way, using
the right fortran compiler with all the right flags.
We plan on leveraging the impressive body of work in the
numpy.distutils.fcompiler package for this purpose; I don't think it
would be too hard to compile the 'genconfig.f95' into an object file,
but we then need to compile it to an executable.
Is there a way for numpy.distutils to compile a fortran source file
into an executable? I'm not well-versed in the black arts of
distutils or numpy.distutils. I know the basics and am quickly
reading up on it -- any pointers would be very appreciated.
Thanks,
Kurt Smith
More information about the NumPy-Discussion
mailing list