Re: [f2py] Override f2py compiler settings

Skipper Seabold <[email protected]> Fri, 28 Mar 2014 15:17:58 -0400
Newsgroups gmane.comp.python.f2py.user
Message-ID <CAKF=DjurssF6G0M4Q19AMvhWzoFv9TWrfrDdP3=4uWUNHsC3Mw@mail.gmail.com>
On Fri, Mar 28, 2014 at 3:07 PM, Justin M Wozniak <wozniak-zhzY/AYb9nBYTrM/[email protected]> wrote:
> On 03/28/2014 09:46 AM, Sturla Molden wrote:
>> Justin M Wozniak <wozniak-zhzY/AYb9nBYTrM/[email protected]> wrote:
>>>       I am trying to run f2py on the Blue Gene/Q.  I am running it as:
>>>
>>> f2py -c -m lib_discus  ...
>>>
>>> I get:
>>>
>>> build_src: building npy-pkg config files
>>> running build_ext
>>> error: don't know how to compile C/C++ code on platform 'posix' with
>>> 'gnu' compiler
>>>
>>>       Is there some way to override the detected platform (to linux?), or
>>> to completely override the compiler settings?
>>>       Thanks
>> --fcompiler=gnu is the g77 compiler (only Fortran 77)
>> --fcompiler=gnu95 is the gfortran compiler (any Fortran version)
>
> Thanks- gnu95 seems to work.
>
> Now, I would really like to use the IBM XL compilers.  I used
> --fcompiler=ibm .
> It doesn't work so I added some debugging statements in f2py:
>
> platform: linux2
> args: ()
> get_version
> CCompiler_get_version()
> environment _get_var: compiler_f90
> /soft/compilers/ibmcmp-nov2013/xlf/bg/14.1/bin/xlf90
> environment _get_var: compiler_f77
> /soft/compilers/ibmcmp-nov2013/xlf/bg/14.1/bin/xlf
> environment _get_var: compiler_fix
> /soft/compilers/ibmcmp-nov2013/xlf/bg/14.1/bin/xlf90
> environment _get_var: linker_so
> /soft/compilers/ibmcmp-nov2013/xlf/bg/14.1/bin/xlf95
> environment _get_var: version_cmd
> /soft/compilers/ibmcmp-nov2013/xlf/bg/14.1/bin/xlf
>
> Ultimately results in:
>
>    File
> "/home/wozniak/Public/sfw/ppc64-login/Python-2.7.6/lib/python2.7/site-packages/numpy/distutils/fcompiler/__init__.py",
> line 433, in get_version
>      raise CompilerNotFound()
>
> I feel like if I could manually set the compiler locations and flags I
> could fix this but I don't know how to do that.

You can find the available compilers with

f2py -c --help-fcompiler

See here for manually setting locations. The compiler flag options are
down the page. You can also just use f2py -h.

http://cens.ioc.ee/projects/f2py2e/usersguide/

>
>> Normally you should use the same C compiler as was used to build Python,
>> which is nearly always the system cc. Trying to control which C compiler to
>> use is usually inherently bad on Linux.
>
> This system is kind of complicated- it has many compilers and settings.
> It's a cross-compiled system.
>
> --
> Justin M Wozniak
>
>
> _______________________________________________
> f2py-users mailing list
> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> http://cens.ioc.ee/mailman/listinfo/f2py-users