f2py更改Intel iFort编译器的“编译器实例属性”

时间:2017-02-22 11:31:01

标签: python python-2.7 fortran intel-fortran f2py

我一直在尝试使用f2py将示例fortran代码与python连接起来。 f2py检测所有已安装的fortran编译器&可以使用 f2py -c --help-fcompiler 命令进行检查。其输出显示以下默认编译器选项

IntelEM64TFCompiler instance properties:
  archiver        =
                    ['/data/installed_softwares/intel/compilers_and_libraries_
                    2017.0.098/linux/bin/intel64/ifort', '-cr']
  compile_switch  = '-c'
  compiler_f77    =
                    ['/data/installed_softwares/intel/compilers_and_libraries_
                    2017.0.098/linux/bin/intel64/ifort', '-FI', '-fPIC', '-
                    openmp -fp-model strict -O1', '']
  compiler_f90    =
                    ['/data/installed_softwares/intel/compilers_and_libraries_
                    2017.0.098/linux/bin/intel64/ifort', '-FR', '-fPIC', '-
                    openmp -fp-model strict -O1', '']
  compiler_fix    =
                    ['/data/installed_softwares/intel/compilers_and_libraries_
                    2017.0.098/linux/bin/intel64/ifort', '-FI', '-fPIC', '-
                    openmp -fp-model strict -O1', '']
  libraries       = []
  library_dirs    = []
  linker_exe      = None
  linker_so       =
                    ['/data/installed_softwares/intel/compilers_and_libraries_
                    2017.0.098/linux/bin/intel64/ifort', '-shared', '-shared',
                    '-nofor_main']
  object_switch   = '-o '
  ranlib          =
                    ['/data/installed_softwares/intel/compilers_and_libraries_
                    2017.0.098/linux/bin/intel64/ifort']
  version         = LooseVersion ('17.0.0.098')
  version_cmd     =
                    ['/data/installed_softwares/intel/compilers_and_libraries_
                    2017.0.098/linux/bin/intel64/ifort', '-FI', '-V', '-c',
                    '/tmp/tmpCERvad/M4s2ST.f', '-o',
                    '/tmp/tmpCERvad/M4s2ST.o']

问题是,在编译期间,ifort遇到错误,因为在较新版本的iFort&中已经弃用了f2py默认编译器设置'-openmp'。它必须被'-qopenmp'取代。编译时错误如下所示

gcc: /tmp/tmpsaNHp2/src.linux-x86_64-2.7/fortranobject.c
In file included from /data/installed_softwares/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1777:0,
                 from /data/installed_softwares/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                 from /data/installed_softwares/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from /tmp/tmpsaNHp2/src.linux-x86_64-2.7/fortranobject.h:13,
                 from /tmp/tmpsaNHp2/src.linux-x86_64-2.7/fortranobject.c:2:
/data/installed_softwares/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " \
  ^
compiling Fortran sources
Fortran f77 compiler: /data/installed_softwares/intel/compilers_and_libraries_2017.0.098/linux/bin/intel64/ifort -FI -fPIC -openmp -fp-model strict -O1 
Fortran f90 compiler: /data/installed_softwares/intel/compilers_and_libraries_2017.0.098/linux/bin/intel64/ifort -FR -fPIC -openmp -fp-model strict -O1 
Fortran fix compiler: /data/installed_softwares/intel/compilers_and_libraries_2017.0.098/linux/bin/intel64/ifort -FI -fPIC -openmp -fp-model strict -O1 
compile options: '-I/tmp/tmpsaNHp2/src.linux-x86_64-2.7 -I/data/installed_softwares/anaconda2/lib/python2.7/site-packages/numpy/core/include -I/data/installed_softwares/anaconda2/include/python2.7 -c'
ifort:f90: test_f2py.f90
ifort: command line remark #10411: option '-openmp' is deprecated and will be removed in a future release. Please use the replacement option '-qopenmp'
/data/installed_softwares/intel/compilers_and_libraries_2017.0.098/linux/bin/intel64/ifort -shared -shared -nofor_main /tmp/tmpsaNHp2/tmp/tmpsaNHp2/src.linux-x86_64-2.7/test_f2pymodule.o /tmp/tmpsaNHp2/tmp/tmpsaNHp2/src.linux-x86_64-2.7/fortranobject.o /tmp/tmpsaNHp2/test_f2py.o -L/data/installed_softwares/anaconda2/lib -lpython2.7 -o ./test_f2py.so
Removing build directory /tmp/tmpsaNHp2

有谁知道如何更改f2py自动检测到的默认编译选项?或者,是否有办法强制f2py使用用户指定的编译选项进行编译&忽略默认值?

0 个答案:

没有答案