4

I have a Fortran 90 code, with OpenMP implemented for some parts. Now to compile the Fortran code using f2py with OpenMP support I have to pass the f90 compiler flags. Now the code should compile with OpenMP support only if I provide the OpenMP relevant flag, unless it must be compiled as a normal serial code. This works as expected for gfortran but for ifort it doesn't. Lets explain this,

if I run, (gfortran serial mode)

f2py -c adt.f90 -m adt_module 
*Gives output (last few lines)*
Fortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops

(gfortran parallel mode)

f2py -c adt.f90 -m adt_module --f90flags='-fopenmp' -lgomp 
*output*
Fortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -fopenmp -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fopenmp -fPIC -O3 -funroll-loops

As you can clearly see there is no -fopenmp flag during the compilation in serial mode, as expected as I haven't pass the required flag

Now for ifort

(ifort parallel mode)

f2py -c adt.f90 -m adt_module --fcompiler=intelem --f90flags='-qopenmp' -liomp5
*Output*
Fortran f77 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -fPIC -fp-model strict -O1 -qopenmp 
Fortran f90 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FR -qopenmp -fPIC -fp-model strict -O1 -qopenmp 
Fortran fix compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -qopenmp -fPIC -fp-model strict -O1 -qopenmp

(ifort serial mode)

f2py -c adt.f90 -m adt_module --fcompiler=intelem
*Output*
Fortran f77 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -fPIC -fp-model strict -O1 -qopenmp 
Fortran f90 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FR -fPIC -fp-model strict -O1 -qopenmp 
Fortran fix compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -fPIC -fp-model strict -O1 -qopenmp

Now, here's the problem, see here compiling is done with -qopenmp flag for serial mode but I haven't passed it in command line. Why is it happening when compiling with ifort but not with gfortran? And how to resolve this?

Eular
  • 1,707
  • 4
  • 26
  • 50

0 Answers0