0

I've been trying to interface an example fortran code with python using f2py. f2py detects all installed fortran compilers & can be checked with the command f2py -c --help-fcompiler. The output of this shows the following default compiler options

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']

The problem is, during compilation, ifort runs into an error since the f2py default compiler setting '-openmp' has been deprecated in the newer versions of iFort & it has to be replaced by '-qopenmp'. The compile time error is as shown below

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

Does anyone know how to change the default compile options auto-detected by f2py? Or else, is there a way to force f2py to compile with the user specified compile options & ignore the default values?

  • 1
    I think `f2py -h` might be of use to you here as it will display a help message describing the different options available. In particular I think you might find `--f90flags` and `--opt` option flags useful to control what is used here. This doesn't change the defaults but allows you to override them. – d_1999 Feb 22 '17 at 11:34
  • That's just an informational message from ifort, not an error (yet). You can ignore it. – Steve Lionel Feb 23 '17 at 16:20

0 Answers0