Using Fortran libraries from Python?

Harry George harry.g.george at boeing.com
Thu Jun 17 21:28:37 CEST 2004


Carl <phleum_nospam at chello.se> writes:

> I have experimented with f2c and swig-generated wrappers to create python
> modules from Fortran files. 
> 
> I think I'm missing something when I'm building the Python module, because
> when I import the built module the Python interpreter returns the
> following:
> 
> >>> import LDSsobol
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "LDSsobol.py", line 4, in ?
>     import _LDSsobol
> ImportError: /usr/lib/libf2c.so.0: undefined symbol: MAIN__
> 
> This is how I built LDSsobol:
> 
> > gcc -c LDSsobol.c
> > gcc -c LDSsobol_wrap.c -I/usr/include/python
> > gcc -shared LDSsobol.o LDSsobol_wrap.o -l f2c -o _LDSsobol.so
> 
> Any help is appreciated!
> 
> Carl

Did you start with pyfort?
http://sourceforge.net/projects/pyfortran

I haven't used it personally, but it seems to be addressing your
concerns, without ad hoc SWIGing.

-- 
harry.g.george at boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 342-0007



More information about the Python-list mailing list