Pearu Peterson | 17 Jul 20:03 2008
Picon

Re: [f2py] f2py can't find ifort

On Thu, Jul 17, 2008 at 4:13 PM, Ryan Sobash <rsobash@...> wrote:
> On Thu, Jul 17, 2008 at 2:00 AM, Pearu Peterson
> <pearu.peterson@...> wrote:
>> On Thu, Jul 17, 2008 at 1:02 AM, Ryan Sobash <rsobash@...> wrote:
>>> Although the output indicates f2py found my ifort executable, it fails
>>> by saying it can't find a Fortran compiler. It works fine with
>>> gfortran, but I want it to use ifort (the code runs 5x faster compiled
>>> with ifort).
>>>
>>> It's probably something simple...I'm a f2py novice. Below is the
>>> output when I run f2py... Thanks!
>>>
>> ...
>>> warning: build_ext: f77_compiler=intel is not available.
>>
>> What is exactly the f2py command line that you are using?
>>
>> Pearu
>
> I was able to have f2py use the ifort compiler with the following command:
>
>  f2py --f77exec=/opt/intel/fc/10.1.013/bin/ifort -m modulename -c filename.f

This command would use gcc for linking the extension module but it
is crucial to use ifort for that. Otherwise one needs to specify compiler
libraries and library paths manually which is not an optimal solution.
For optimal solution, see below.

> Although, when I import the module I get an ImportError:
>
> ImportError: ./probs.so: undefined symbol: for_write_seq_lis
>
> I assume I need to manually link in some libraries?

You should first setup the environment properly for intel fortran compiler,
read its installation instructions. (It is quite common mistake to ignore
these instructions and as a result, there will be difficulties in using the
Intel compilers. It's not enough to specify the path to the compiler executable,
one also needs setup intel shared library paths that the final shared
library needs).

If this is done properly, then use the following command

  f2py -c --fcompiler=intel -m modulename filename.f

that should now detect intel compiler and use appropiate
linker commands to build a working extension module.

You can also execute

  f2py -c --help-fcompiler

to see which compilers are detected and then use appropiate --fcompiler option.

HTH,
Pearu

Gmane