Re: [f2py] Override f2py compiler settings

1,264 views
Skip to first unread message

Justin M Wozniak

unread,
Mar 28, 2014, 3:07:04 PM3/28/14
to For users of the f2py program
On 03/28/2014 09:46 AM, Sturla Molden wrote:
> Justin M Wozniak <woz...@mcs.anl.gov> 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


Skipper Seabold

unread,
Mar 28, 2014, 3:17:58 PM3/28/14
to For users of the f2py program
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-...@cens.ioc.ee
> http://cens.ioc.ee/mailman/listinfo/f2py-users

Justin M Wozniak

unread,
Mar 27, 2014, 8:02:45 PM3/27/14
to f2py-...@cens.ioc.ee
Hi
I am trying to run f2py on the Blue Gene/Q. I am running it as:

f2py -c -m lib_discus --compiler=gnu --fcompiler=gnu ...

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

--
Justin M Wozniak


Sturla Molden

unread,
Mar 28, 2014, 10:46:33 AM3/28/14
to f2py-...@cens.ioc.ee
Justin M Wozniak <woz...@mcs.anl.gov> wrote:
--fcompiler=gnu is the g77 compiler (only Fortran 77)
--fcompiler=gnu95 is the gfortran compiler (any Fortran version)

The C compiler should default to system CC on Unix-like systems. It is
called UnixCCompiler in distutils. You can override it like this:

$ export CC=gcc
$ export CXX=g++

There is no "gnu" C compiler in distutils.

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. The only exception is if you have
built your whole Python and NumPy stack with a different compiler than the
vendor supplied (e.g. Intel icc instead of GNU gcc).

On Windows, however, controlling the C compiler is very important. Here the
GNU compilers are called "mingw" or "cygwin". The option --compiler to
f2py and distutils is mostly useful on Windows.

Sturla


Sturla Molden

unread,
Mar 28, 2014, 3:43:59 PM3/28/14
to f2py-...@cens.ioc.ee
Justin M Wozniak <woz...@mcs.anl.gov> wrote:
> Now, I would really like to use the IBM XL compilers. I used
> --fcompiler=ibm .

It seems to be supported:

https://github.com/numpy/numpy/blob/master/numpy/distutils/fcompiler/ibm.py

>> 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.

Same rule applies to cross-compilation: Point CC to whatever C compiler you
want to use. There is just one C compiler class for Unix/Linux in
distutils.

--compiler is for choosing between Microsoft Visual C++, Borland C++
Builder, MinGW GCC and Cygwin GCC on Windows. You cannot use it for
anything on Linux.

Sturla


Reply all
Reply to author
Forward
0 new messages