F2PY problems with PGI compilers
Good afternoon! I'm trying to build a Python module using F2PY on a simple Fortran code using the PGI 17.4 community compilers. I'm using Conda 4.3.21 with Python 2.7.13 and F2PY 2. The command line I'm using is, f2py --compiler=pg --fcompiler=pg -c -m mdevice mdevice.f90 The output from f2py is at the end of the email. Any suggestions are greatly appreciated. Thanks! Jeff Output from f2py: 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/tmptN1fdp/src.linux-x86_64-2.7/mdevicemodule.c creating /tmp/tmptN1fdp/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/tmptN1fdp/src.linux-x86_64-2.7/mdevicemodule.c" adding '/tmp/tmptN1fdp/src.linux-x86_64-2.7/fortranobject.c' to sources. adding '/tmp/tmptN1fdp/src.linux-x86_64-2.7' to include_dirs. copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmptN1fdp/src.linux-x86_64-2.7 copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmptN1fdp/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
On Sat, Aug 5, 2017 at 7:24 AM, Jeff Layton
Good afternoon!
I'm trying to build a Python module using F2PY on a simple Fortran code using the PGI 17.4 community compilers.
I'm using Conda 4.3.21 with Python 2.7.13 and F2PY 2. The command line I'm using is,
f2py --compiler=pg --fcompiler=pg -c -m mdevice mdevice.f90
The output from f2py is at the end of the email. Any suggestions are greatly appreciated.
--compiler=pg seems wrong, that specifies the C/C++ compiler to use not the Fortran compiler. Hence you get the error "don't know how to compile C/C++ code on platform 'posix' with 'pg' compiler". Try just leaving that off (thereby using the default C compiler you have installed, probably gcc). Ralf
Thanks!
Jeff
Output from f2py:
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/tmptN1fdp/src.linux-x86_64-2.7/mdevicemodule.c creating /tmp/tmptN1fdp/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/tmptN1fdp/src.linux-x86_ 64-2.7/mdevicemodule.c" adding '/tmp/tmptN1fdp/src.linux-x86_64-2.7/fortranobject.c' to sources. adding '/tmp/tmptN1fdp/src.linux-x86_64-2.7' to include_dirs. copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmptN1fdp/src.linux-x86_64-2.7 copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmptN1fdp/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
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
+SciPy list
On Sat, Aug 5, 2017 at 7:24 AM, Jeff Layton
mailto:laytonjb@att.net> wrote: Good afternoon!
I'm trying to build a Python module using F2PY on a simple Fortran code using the PGI 17.4 community compilers.
I'm using Conda 4.3.21 with Python 2.7.13 and F2PY 2. The command line I'm using is,
f2py --compiler=pg --fcompiler=pg -c -m mdevice mdevice.f90
The output from f2py is at the end of the email. Any suggestions are greatly appreciated.
--compiler=pg seems wrong, that specifies the C/C++ compiler to use not the Fortran compiler. Hence you get the error "don't know how to compile C/C++ code on platform 'posix' with 'pg' compiler". Try just leaving that off (thereby using the default C compiler you have installed, probably gcc).
Ralf - thanks for the response! I had tried that before and F2PY still thinks it's using the PGI C compiler: 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/tmpkxCUbk/src.linux-x86_64-2.7/mdevicemodule.c creating /tmp/tmpkxCUbk/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/tmpkxCUbk/src.linux-x86_64-2.7/mdevicemodule.c" adding '/tmp/tmpkxCUbk/src.linux-x86_64-2.7/fortranobject.c' to sources. adding '/tmp/tmpkxCUbk/src.linux-x86_64-2.7' to include_dirs. copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmpkxCUbk/src.linux-x86_64-2.7 copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmpkxCUbk/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/tmpkxCUbk/tmp creating /tmp/tmpkxCUbk/tmp/tmpkxCUbk creating /tmp/tmpkxCUbk/tmp/tmpkxCUbk/src.linux-x86_64-2.7 compile options: '-I/tmp/tmpkxCUbk/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/tmpkxCUbk/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/tmpkxCUbk/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/tmpkxCUbk/src.linux-x86_64-2.7/mdevicemodule.c -o /tmp/tmpkxCUbk/tmp/tmpkxCUbk/src.linux-x86_64-2.7/mdevicemodule.o" failed with exit status 1 I'm definitely at a lose here. I have no idea how to make F2PY work with the PGI compilers. I'm beginning to think F2PY is completely borked unless you use the defaults (gcc). Thanks! Jeff
Thanks!
Jeff
Output from f2py:
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/tmptN1fdp/src.linux-x86_64-2.7/mdevicemodule.c creating /tmp/tmptN1fdp/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/tmptN1fdp/src.linux-x86_64-2.7/mdevicemodule.c" adding '/tmp/tmptN1fdp/src.linux-x86_64-2.7/fortranobject.c' to sources. adding '/tmp/tmptN1fdp/src.linux-x86_64-2.7' to include_dirs. copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmptN1fdp/src.linux-x86_64-2.7 copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmptN1fdp/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
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org mailto:NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion https://mail.python.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
On Mon, Aug 14, 2017 at 7:24 AM, Jeff Layton
+SciPy list
On Sat, Aug 5, 2017 at 7:24 AM, Jeff Layton
wrote: Good afternoon!
I'm trying to build a Python module using F2PY on a simple Fortran code using the PGI 17.4 community compilers.
I'm using Conda 4.3.21 with Python 2.7.13 and F2PY 2. The command line I'm using is,
f2py --compiler=pg --fcompiler=pg -c -m mdevice mdevice.f90
The output from f2py is at the end of the email. Any suggestions are greatly appreciated.
--compiler=pg seems wrong, that specifies the C/C++ compiler to use not the Fortran compiler. Hence you get the error "don't know how to compile C/C++ code on platform 'posix' with 'pg' compiler". Try just leaving that off (thereby using the default C compiler you have installed, probably gcc).
Ralf - thanks for the response! I had tried that before and F2PY still thinks it's using the PGI C compiler:
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/tmpkxCUbk/src.linux-x86_64-2.7/mdevicemodule.c creating /tmp/tmpkxCUbk/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/tmpkxCUbk/src.linux-x86_ 64-2.7/mdevicemodule.c" adding '/tmp/tmpkxCUbk/src.linux-x86_64-2.7/fortranobject.c' to sources. adding '/tmp/tmpkxCUbk/src.linux-x86_64-2.7' to include_dirs. copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmpkxCUbk/src.linux-x86_64-2.7 copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmpkxCUbk/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/tmpkxCUbk/tmp creating /tmp/tmpkxCUbk/tmp/tmpkxCUbk creating /tmp/tmpkxCUbk/tmp/tmpkxCUbk/src.linux-x86_64-2.7 compile options: '-I/tmp/tmpkxCUbk/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/tmpkxCUbk/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/tmpkxCUbk/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/tmpkxCUbk/src.linux-x86_64-2.7/mdevicemodule.c -o /tmp/tmpkxCUbk/tmp/tmpkxCUbk/src.linux-x86_64-2.7/mdevicemodule.o" failed with exit status 1
I'm definitely at a lose here. I have no idea how to make F2PY work with the PGI compilers. I'm beginning to think F2PY is completely borked unless you use the defaults (gcc).
That's not the case. Here is an example when using the Intel Fortran compiler together with either MSVC or Intel C compilers: https://software.intel.com/en-us/articles/building-numpyscipy-with-intel-mkl... I notice there that in all cases the C compiler is explicitly specified. Did you also try ``--compiler=gcc --fcompiler=pg``? Also, I'm not sure how often this is done with f2py directly; I've only ever used the --fcompiler flag via ``python setup.py config --fcompiler=..<etc>``, invoking f2py under the hood. It could be that doing this directly is indeed broken (or was never supported in the first place). Ralf
Thanks!
Jeff
Thanks!
Jeff
Output from f2py:
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/tmptN1fdp/src.linux-x86_64-2.7/mdevicemodule.c creating /tmp/tmptN1fdp/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/tmptN1fdp/src.linux-x86_64-2.7/mdevicemodule.c" adding '/tmp/tmptN1fdp/src.linux-x86_64-2.7/fortranobject.c' to sources. adding '/tmp/tmptN1fdp/src.linux-x86_64-2.7' to include_dirs. copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmptN1fdp/src.linux-x86_64-2.7 copying /home/laytonjb/anaconda2/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmptN1fdp/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
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing listNumPy-Discussion@python.orghttps://mail.python.org/mailman/listinfo/numpy-discussion
Ralf Gommers kirjoitti 14.08.2017 klo 09:51:
I'm definitely at a lose here. I have no idea how to make F2PY work with the PGI compilers. I'm beginning to think F2PY is completely borked unless you use the defaults (gcc).
That's not the case. Here is an example when using the Intel Fortran compiler together with either MSVC or Intel C compilers: https://software.intel.com/en-us/articles/building-numpyscipy-with-intel-mkl...
Note that it is not necessary to use f2py for compiling. It can also just generate the C and fortran source files necessary --- although you need to also compile and link in fortranobject.[ch] which are found inside the numpy folders, and supply the correct Python and numpy include paths see numpy.get_includes().
On 08/14/2017 03:51 AM, Ralf Gommers wrote:
I'm definitely at a lose here. I have no idea how to make F2PY work with the PGI compilers. I'm beginning to think F2PY is completely borked unless you use the defaults (gcc).
That's not the case. Here is an example when using the Intel Fortran compiler together with either MSVC or Intel C compilers: https://software.intel.com/en-us/articles/building-numpyscipy-with-intel-mkl...
I notice there that in all cases the C compiler is explicitly specified. Did you also try ``--compiler=gcc --fcompiler=pg``?
Also, I'm not sure how often this is done with f2py directly; I've only ever used the --fcompiler flag via ``python setup.py config --fcompiler=..<etc>``, invoking f2py under the hood. It could be that doing this directly is indeed broken (or was never supported in the first place).
Ralf
Point taken. I don't use Windows too much and I don't use the Intel compiler any more (it's not free for non-commercial use :) ). I tried using "--compiler=gcc --fcompiler=pg" and I get the same answer at the very end. running build_ext error: don't know how to compile C/C++ code on platform 'posix' with 'gcc' compiler Good point about f2py. I'm using the Anaconda distribution of f2py and that may have limitations with respect to the PGI compiler. I may download the f2py source and build it to include PGI support. Maybe that will fix the problem. Thanks! Jeff
On 08/14/2017 10:19 AM, Jeff Layton wrote:
On 08/14/2017 03:51 AM, Ralf Gommers wrote:
I'm definitely at a lose here. I have no idea how to make F2PY work with the PGI compilers. I'm beginning to think F2PY is completely borked unless you use the defaults (gcc).
That's not the case. Here is an example when using the Intel Fortran compiler together with either MSVC or Intel C compilers: https://software.intel.com/en-us/articles/building-numpyscipy-with-intel-mkl...
I notice there that in all cases the C compiler is explicitly specified. Did you also try ``--compiler=gcc --fcompiler=pg``?
Also, I'm not sure how often this is done with f2py directly; I've only ever used the --fcompiler flag via ``python setup.py config --fcompiler=..<etc>``, invoking f2py under the hood. It could be that doing this directly is indeed broken (or was never supported in the first place).
Ralf
Point taken. I don't use Windows too much and I don't use the Intel compiler any more (it's not free for non-commercial use :) ).
I tried using "--compiler=gcc --fcompiler=pg" and I get the same answer at the very end.
running build_ext error: don't know how to compile C/C++ code on platform 'posix' with 'gcc' compiler
Good point about f2py. I'm using the Anaconda distribution of f2py and that may have limitations with respect to the PGI compiler. I may download the f2py source and build it to include PGI support. Maybe that will fix the problem.
Thanks!
Jeff
On Tue, Aug 15, 2017 at 2:19 AM, Jeff Layton
On 08/14/2017 03:51 AM, Ralf Gommers wrote:
I'm definitely at a lose here. I have no idea how to make F2PY work with the PGI compilers. I'm beginning to think F2PY is completely borked unless you use the defaults (gcc).
That's not the case. Here is an example when using the Intel Fortran compiler together with either MSVC or Intel C compilers: https://software.intel.com/en-us/articles/building- numpyscipy-with-intel-mkl-and-intel-fortran-on-windows
I notice there that in all cases the C compiler is explicitly specified. Did you also try ``--compiler=gcc --fcompiler=pg``?
Also, I'm not sure how often this is done with f2py directly; I've only ever used the --fcompiler flag via ``python setup.py config --fcompiler=..<etc>``, invoking f2py under the hood. It could be that doing this directly is indeed broken (or was never supported in the first place).
Ralf
Point taken. I don't use Windows too much and I don't use the Intel compiler any more (it's not free for non-commercial use :) ).
I tried using "--compiler=gcc --fcompiler=pg" and I get the same answer at the very end.
running build_ext error: don't know how to compile C/C++ code on platform 'posix' with 'gcc' compiler
Good point about f2py. I'm using the Anaconda distribution of f2py and that may have limitations with respect to the PGI compiler. I may download the f2py source and build it to include PGI support. Maybe that will fix the problem.
That won't make a difference, all the build config code is pure Python. Anaconda will give you the same results as building from source. Ralf
Thanks!
Jeff
participants (3)
-
Jeff Layton
-
Pauli Virtanen
-
Ralf Gommers