Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-03-11 Thread Nils Wagner
On Mon, 22 Feb 2010 22:18:23 +0900 David Cournapeau courn...@gmail.com wrote: On Mon, Feb 22, 2010 at 10:01 PM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: ar x test.a gfortran -shared *.o -o libtest.so -lg2c to build a shared library. The additional option -lg2c was necessary due

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-03-11 Thread Dag Sverre Seljebotn
Nils Wagner wrote: On Mon, 22 Feb 2010 22:18:23 +0900 David Cournapeau courn...@gmail.com wrote: On Mon, Feb 22, 2010 at 10:01 PM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: ar x test.a gfortran -shared *.o -o libtest.so -lg2c to build a shared library. The additional

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-03-11 Thread Dag Sverre Seljebotn
Nils Wagner wrote: On Thu, 11 Mar 2010 13:01:33 +0100 Dag Sverre Seljebotn da...@student.matnat.uio.no wrote: Nils Wagner wrote: On Mon, 22 Feb 2010 22:18:23 +0900 David Cournapeau courn...@gmail.com wrote: On Mon, Feb 22, 2010 at 10:01 PM, Nils Wagner

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-03-11 Thread Nils Wagner
On Thu, 11 Mar 2010 13:42:43 +0100 Dag Sverre Seljebotn da...@student.matnat.uio.no wrote: Nils Wagner wrote: On Thu, 11 Mar 2010 13:01:33 +0100 Dag Sverre Seljebotn da...@student.matnat.uio.no wrote: Nils Wagner wrote: On Mon, 22 Feb 2010 22:18:23 +0900 David Cournapeau

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-23 Thread Nils Wagner
On Mon, 22 Feb 2010 22:18:23 +0900 David Cournapeau courn...@gmail.com wrote: On Mon, Feb 22, 2010 at 10:01 PM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: ar x test.a gfortran -shared *.o -o libtest.so -lg2c to build a shared library. The additional option -lg2c was necessary due

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-22 Thread Nils Wagner
On Thu, 18 Feb 2010 22:29:39 +0900 David Cournapeau courn...@gmail.com wrote: On Thu, Feb 18, 2010 at 10:22 PM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: On Thu, 18 Feb 2010 11:55:07 +0100  Matthieu Brucher matthieu.bruc...@gmail.com wrote: Ok I have extracted the *.o files from the

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-22 Thread David Cournapeau
On Mon, Feb 22, 2010 at 10:01 PM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: ar x test.a gfortran -shared *.o -o libtest.so -lg2c to build a shared library. The additional option -lg2c was necessary due to an undefined symbol: s_cmp You should avoid the -lg2c option at any cost if

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-22 Thread Nils Wagner
On Mon, 22 Feb 2010 22:18:23 +0900 David Cournapeau courn...@gmail.com wrote: On Mon, Feb 22, 2010 at 10:01 PM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: ar x test.a gfortran -shared *.o -o libtest.so -lg2c to build a shared library. The additional option -lg2c was necessary due

[Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Nils Wagner
Hi all, I have a static library (*.a) compiled by gfortran but no source files. How can I call routines from that library using python ? Any pointer would be appreciated. Thanks in advance. Nils ___

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread David Cournapeau
Nils Wagner wrote: Hi all, I have a static library (*.a) compiled by gfortran but no source files. How can I call routines from that library using python ? Is there any kind of interface (.h, etc...) ? If this is a proprietary library, there has to be something so that it can be called

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Nils Wagner
On Thu, 18 Feb 2010 18:32:18 +0900 David Cournapeau da...@silveregg.co.jp wrote: Nils Wagner wrote: Hi all, I have a static library (*.a) compiled by gfortran but no source files. How can I call routines from that library using python ? Is there any kind of interface (.h, etc...) ?

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread David Cournapeau
Nils Wagner wrote: On Thu, 18 Feb 2010 18:32:18 +0900 David Cournapeau da...@silveregg.co.jp wrote: Nils Wagner wrote: Hi all, I have a static library (*.a) compiled by gfortran but no source files. How can I call routines from that library using python ? Is there any kind of

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Matthieu Brucher
You may have to convert the .a library to a .so library. And this is where I hope that the library is compiled with fPIC (which is generally not the case for static libraries). If it is not the case, you will not be able to compile it as a shared library and thus not be able to use it from

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Nils Wagner
On Thu, 18 Feb 2010 10:15:51 + (UTC) Neil Crighton neilcrigh...@gmail.com wrote: Nils Wagner nwagner at iam.uni-stuttgart.de writes: Hi David, you are right. It's a proprietary library. I found a header file (*.h) including prototype declarations of externally callable procedures.

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread David Cournapeau
Nils Wagner wrote: How do I convert the .a library to a .so library ? You first uncompress the .a into a temporary directory, with ar x on Linux. Then, you group the .o together with gfortran -shared $LIST_OF_OBJECT + a few options. You can also look at how Atlas does it in its makefile. As

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Nils Wagner
On Thu, 18 Feb 2010 19:21:03 +0900 David Cournapeau da...@silveregg.co.jp wrote: Nils Wagner wrote: On Thu, 18 Feb 2010 18:32:18 +0900 David Cournapeau da...@silveregg.co.jp wrote: Nils Wagner wrote: Hi all, I have a static library (*.a) compiled by gfortran but no source files.

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Nils Wagner
On Thu, 18 Feb 2010 19:30:10 +0900 David Cournapeau da...@silveregg.co.jp wrote: Nils Wagner wrote: How do I convert the .a library to a .so library ? You first uncompress the .a into a temporary directory, with ar x on Linux. Then, you group the .o together with gfortran -shared

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread George Nurser
Hi Nils, I've not tried it, but you might be able to interface with f2py your own fortran subroutine that calls the library. Then issue the f2py command with extra arguments -llibname -Ldirectory with lib. See section 5 of http://cens.ioc.ee/projects/f2py2e/usersguide/index.html#command-f2py

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Matthieu Brucher
Ok I have extracted the *.o files from the static library. Applying the file command to the object files yields ELF 64-bit LSB relocatable, AMD x86-64, version 1 (SYSV), not stripped What's that supposed to mean ? It means that each object file is an object file compiled with -fPIC, so

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Matthieu Brucher
If header files are provided, the work done by f2py is almost done. But you don't know the real Fortran interface, so you still have to use ctypes over f2py. Matthieu 2010/2/18 George Nurser gnur...@googlemail.com: Hi Nils, I've not tried it, but you might be able to interface with f2py your

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread George Nurser
I'm suggesting writing a *new* Fortran interface, coupled with f2py. The original library just needs to be linked to the new .so generated by f2py. I am hoping (perhaps optimistically) that can be done in the Fortran compilation... --George. On 18 February 2010 10:56, Matthieu Brucher

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Matthieu Brucher
If Nils has no access to the Fortran interface (and I don't think he has, unless there is some .mod file somewhere?), he shouldn't use f2py. Even if you know that the Fortran routine is named XXX, you don't know how the arguments must be given. Addressing the C interface directly is much safer.

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Nils Wagner
On Thu, 18 Feb 2010 11:55:07 +0100 Matthieu Brucher matthieu.bruc...@gmail.com wrote: Ok I have extracted the *.o files from the static library. Applying the file command to the object files yields ELF 64-bit LSB relocatable, AMD x86-64, version 1 (SYSV), not stripped What's that

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread David Cournapeau
On Thu, Feb 18, 2010 at 10:22 PM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: On Thu, 18 Feb 2010 11:55:07 +0100  Matthieu Brucher matthieu.bruc...@gmail.com wrote: Ok I have extracted the *.o files from the static library. Applying the file command to the object files yields ELF 64-bit

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Dag Sverre Seljebotn
David Cournapeau wrote: On Thu, Feb 18, 2010 at 10:22 PM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: On Thu, 18 Feb 2010 11:55:07 +0100 Matthieu Brucher matthieu.bruc...@gmail.com wrote: Ok I have extracted the *.o files from the static library. Applying the file command to

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Nils Wagner
On Thu, 18 Feb 2010 15:32:12 +0100 Dag Sverre Seljebotn da...@student.matnat.uio.no wrote: David Cournapeau wrote: On Thu, Feb 18, 2010 at 10:22 PM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: On Thu, 18 Feb 2010 11:55:07 +0100 Matthieu Brucher matthieu.bruc...@gmail.com wrote:

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Dag Sverre Seljebotn
Nils Wagner wrote: On Thu, 18 Feb 2010 15:32:12 +0100 Dag Sverre Seljebotn da...@student.matnat.uio.no wrote: David Cournapeau wrote: On Thu, Feb 18, 2010 at 10:22 PM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: On Thu, 18 Feb 2010 11:55:07 +0100 Matthieu

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Dag Sverre Seljebotn
Christopher Barker wrote: Matthieu Brucher wrote: If it is not the case, you will not be able to compile it as a shared library and thus not be able to use it from Python :| maybe not directly with ctypes, but you should be able to call it from Cython (or SWIG, or custom C

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Christopher Barker
Dag Sverre Seljebotn wrote: If it is not compiled with -fPIC, you can't statically link it into any shared library, it has to be statically linked into the final executable (so the standard /usr/bin/python will never work). Shows you what I (don't) know! The joys of closed-source software!

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread Matthieu Brucher
2010/2/18 Christopher Barker chris.bar...@noaa.gov: Dag Sverre Seljebotn wrote: If it is not compiled with -fPIC, you can't statically link it into any shared library, it has to be statically linked into the final executable (so the standard /usr/bin/python will never work). Shows you what I

Re: [Numpy-discussion] Calling routines from a Fortran library using python

2010-02-18 Thread David Cournapeau
Dag Sverre Seljebotn wrote: Well, I think one can make a static executable with C or Cython and embed the Python interpreter. Yes, it is possible, but I think it is fair to say that if you don't know how to write a C extension, statically build numpy into python would be daunting :) David