Showing results for 
Search instead for 
Did you mean: 

Compiling Fortran BLAS and LAPACK interfaces for using with gfortran

Hi. I hope that someone can offer some help with using the MKL BLAS and LAPACK interfaces with gfortran. When I code in a compiled language, it is always in C, and I have no Fortran experience at all. However, I have a need to link some Fortran code to MKL (someone else's code, someone else's makefile), and I am having trouble figuring out how create the gfortran-specific interface libraries for blas95.mod and lapack95.mod. For compatibility reasons, I need to use gfortran, and cannot depend on the Intel precompiled interface modules.
(Note: I'm on a 2010-vintage Mac Pro with 2 6-core Xeon 5670 processors, running Snow Leopard 10.6.4).
Now, I see that on page 7-4 of the MKL Users Guide for MacOSX, there is a suggestion to run something like:

make libem64t FC=pgf95 INSTALL_DIR= interface=lp64

That's simple enough, except that I need FC=gfortran. When I set that flag, I get the errors

f951: error: unrecognized command line option "-module"
f951: error: unrecognized command line option "-auto"
So what it looks like the makefile is doing is calling gfortran using ifort options. When I went into the makefile, it seems to support FC=ifort or FC=pgf95 (whatever that is), but there are no FC=gfortran options. I have played around with the makefile a bit (e.g., replacing -module with -J), and the make script ran, but all I got was a libmkl_blas95_ilp64.a file in the $INSTALL_DIR, and no .mod file. Now, maybe this is OK, and maybe it's not. I have no idea.
I also checked the Intel Knowledgebase, and found an article with the following text:
"Customer should use option /module:path (in Windows environment) or -module path (in Linux and Mac OS) when building the application with Intel Fortran Compiler ( ** ).
For gfrortran or pgf95, please, refer to the corresponding user guides of these compilers."

... which obviously is of absolutely no help.

Is there anyone that might be able to help me out? Otherwise, I seem to have a MKL product that is incompatible with gfortran. And that makes me sad.


Michael Braun
0 Kudos
2 Replies
Black Belt

If your efforts produced a functional libmkl_blas95_ilp64.a, the corresponding .mod files were also produced. You could locate them using the find command.

Alternatively, it is quite easy to produce the module files without using a makefile.

With gfortran 4.5:

$ cp /opt/IFC11/mkl/include/blas.f90 . # copy interface definition files to working directory
$ cp /opt/IFC11/mkl/include/lapack.f90 .
$ gfortran -J. -c blas.f90 lapack.f90 # you can specify where to put the .mod files with the -J option.
$ ls *.mod
blas95.mod lapack95.mod mkl95_lapack.mod
f95_precision.mod mkl95_blas.mod mkl95_precision.mod

Thank you, this was very helpful. I still needed to rewrite the Makefile, but from your example I learned something new about how Fortran compilers work, and it put me on the right track. Much appreciated.