I'm developing a python package which makes use of fortran 90 code with OpenMP directives and I'd like to package it using numpy.distutils. The problem I'm having is that both the compiler flags and the OpenMP libraries are different for different fortran compilers (for example -fopenmp and -lgomp for gfortran and -openmp and -liomp5 for ifort).
I've found that I can successfully pass in the compiler and linking flags once I know the compiler. For example, if I'm certain the user has gfortran I can do,
ext1 = numpy.distutils.core.Extension(
name = 'rabacus_fc',
sources = f90_paths,
extra_f90_compile_args = ["-fopenmp"],
extra_link_args = ["-lgomp"],
)
At first I tried to force the compiler using an extra keyword argument in the call to Extension,
f2py_options = ["--fcompiler=gnu95"]
this returns the error message,
running install
running bdist_egg
running egg_info
running build_src
build_src
building extension "rabacus_fc" sources
f2py options: ['--fcompiler=gnu95']
f2py:> build/src.linux-x86_64-2.7/rabacus_fcmodule.c
Unknown option '--fcompiler=gnu95'
If anyone knows how to correctly pass f2py options as opposed to compiler options that would help.
Next I tried to determine if there is a way to detect which compiler f2py and numpy.distutils is going to use and then use this information to set the proper flags. I haven't found this anywhere and this is where I'm stuck.