Re: [f2py] Override f2py compiler settings

Justin M Wozniak <wozniak-zhzY/AYb9nBYTrM/[email protected]> Fri, 28 Mar 2014 14:07:04 -0500
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
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.

> 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