F2PY + PGI 17.4 issues

Hello,

I’m trying to create a Python module using a simple Fortran code and F2PY. The command line I’m using is,

f2py --fcompiler=pg -c -m mdevice mdevice.f90

I’m using PGI 17.4, conda 4.3.21, Python 2.7.13, F2PY 2.

It’s not even getting to the pgfortran compiler (it fails earlier). The output is below. Any suggestions?

Thanks!

Jeff

running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension “mdevice” sources
f2py options:
f2py:> /tmp/tmpGICCPd/src.linux-x86_64-2.7/mdevicemodule.c
creating /tmp/tmpGICCPd/src.linux-x86_64-2.7
Reading fortran codes…
Reading file ‘mdevice.f90’ (format:free)
Post-processing…
Block: mdevice
Block: devicequery
In: :mdevice:mdevice.f90:devicequery
get_useparameters: no module cudafor info used by devicequery
Post-processing (stage 2)…
Building modules…
Building module “mdevice”…
Constructing wrapper function “devicequery”…
devicequery()
Wrote C/API module “mdevice” to file “/tmp/tmpGICCPd/src.linux-x86_64-2.7/mdevicemodule.c”
adding ‘/tmp/tmpGICCPd/src.linux-x86_64-2.7/fortranobject.c’ to sources.
adding ‘/tmp/tmpGICCPd/src.linux-x86_64-2.7’ to include_dirs.
copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c → /tmp/tmpGICCPd/src.linux-x86_64-2.7
copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h → /tmp/tmpGICCPd/src.linux-x86_64-2.7
build_src: building npy-pkg config files
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
customize PGroupFCompiler
Found executable /opt/pgi/linux86-64/pgidir/pgf90
Found executable /opt/pgi/linux86-64/pgidir/pgf77
Found executable /opt/pgi/linux86-64/17.4/bin/pgfortran
customize PGroupFCompiler using build_ext
building ‘mdevice’ extension
compiling C sources
C compiler: /opt/pgi/linux86-64/pgidir/pgcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC

creating /tmp/tmpGICCPd/tmp
creating /tmp/tmpGICCPd/tmp/tmpGICCPd
creating /tmp/tmpGICCPd/tmp/tmpGICCPd/src.linux-x86_64-2.7
compile options: ‘-I/tmp/tmpGICCPd/src.linux-x86_64-2.7 -I/home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/core/include -I/home/laytonjb/anaconda2/include/python2.7 -c’
pgcc: /tmp/tmpGICCPd/src.linux-x86_64-2.7/mdevicemodule.c
pgcc-Error-Unknown switch: -fno-strict-aliasing
pgcc-Error-Unknown switch: -fwrapv
pgcc-Error-Unknown switch: -Wall
pgcc-Error-Unknown switch: -Wstrict-prototypes
pgcc-Error-Unknown switch: -fno-strict-aliasing
pgcc-Error-Unknown switch: -fwrapv
pgcc-Error-Unknown switch: -Wall
pgcc-Error-Unknown switch: -Wstrict-prototypes
error: Command “/opt/pgi/linux86-64/pgidir/pgcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/tmpGICCPd/src.linux-x86_64-2.7 -I/home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/core/include -I/home/laytonjb/anaconda2/include/python2.7 -c /tmp/tmpGICCPd/src.linux-x86_64-2.7/mdevicemodule.c -o /tmp/tmpGICCPd/tmp/tmpGICCPd/src.linux-x86_64-2.7/mdevicemodule.o” failed with exit status 1

It looks like you are using pgcc with gcc options. There is no need to use pgcc with f2py. So, your options are to either set the configure step to use gcc (CC variable?) or hopefully configure can somehow figure out how to use pgcc compiler options with pgcc.

I’m not sure how that happened but Travis Oliphant from Continuum made a suggestion to change the f2py line to be:

f2py --compiler=pg --fcompiler=pg -c -m mdevice mdevice.f90

It doesn’t solve the problem - the output is below.

Thanks!

Jeff


running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension “mdevice” sources
f2py options:
f2py:> /tmp/tmpAMXFG_/src.linux-x86_64-2.7/mdevicemodule.c
creating /tmp/tmpAMXFG_/src.linux-x86_64-2.7
Reading fortran codes…
Reading file ‘mdevice.f90’ (format:free)
Post-processing…
Block: mdevice
Block: devicequery
In: :mdevice:mdevice.f90:devicequery
get_useparameters: no module cudafor info used by devicequery
Post-processing (stage 2)…
Building modules…
Building module “mdevice”…
Constructing wrapper function “devicequery”…
devicequery()
Wrote C/API module “mdevice” to file “/tmp/tmpAMXFG_/src.linux-x86_64-2.7/mdevicemodule.c”
adding ‘/tmp/tmpAMXFG_/src.linux-x86_64-2.7/fortranobject.c’ to sources.
adding ‘/tmp/tmpAMXFG_/src.linux-x86_64-2.7’ to include_dirs.
copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c → /tmp/tmpAMXFG_/src.linux-x86_64-2.7
copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h → /tmp/tmpAMXFG_/src.linux-x86_64-2.7
build_src: building npy-pkg config files
running build_ext
error: don’t know how to compile C/C++ code on platform ‘posix’ with ‘pg’ compiler

Jeff,

f2py doesn’t support pgcc as a C compiler. What you might try to do is force gcc. I think that would be --compiler=unix, but I’ve found that f2py can (depending on version) sort of ignore that.

My suspicion is that f2py is reading CC. You could try:

env CC=gcc f2py --fcompiler=pg -c -m mdevice mdevice.f90

or set CC in your environment to be gcc (or the appropriate full path). Then I think f2py should be happier.

Matt