Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6956 Discussions

Need help using fortran 95 interfaces

alexism
Beginner
404 Views
Hi everyone,

I'm trying to use the fortran blas 95 interfaces. I haven't used BLAS or intel mkl before. I tried a little test program:
program test
integer, parameter :: N=10
real :: x(N),y(N)
integer :: i
do i=1,10
x(i)=2e0
y(i)=1e0
enddo
res=sdot(x,y)
print*,'SDOT=',res
end program test
and then tried compiling it like so:

ifort test.f90 -o test -L$MKLPATH -lmkl_blas95 -lmkl_lapack -lmkl_ia32 -lguide -lpthread

and then I get the message that it can't find -lmkl_blas95. I then copied over the libmkl_blas95.a file that was created when I built the interface according the the manual to the /mkl/8.1/lib/32/ directory where all the other library files are held. Compiling now works, but when I run the program I get the error

"forrtl: severe (174): SIGSEGV, segmentation fault occurred
Stack trace terminated abnormally."

I don't really understand how to link everything properly, and so any help would be greatly appreciated!








0 Kudos
6 Replies
alexism
Beginner
404 Views
One more question: It is my understanding that the *.so library files are to be dynamically linked and the *.a are to be statically linked. Is this so? If it is the case, how does the linker know which one to use when I issue a command like

ifort test.f90 -o test -L$MKLPATH -lmkl_ia32 -lguide -lpthread

since the libguide has two versions?

Also, I notice that libmkl_blas95.a doesn't have a .so counterpart. Does this mean that it cannot be dynamically linked?

I'm sorry if these are stupid questions--I really am not experienced in these matters. Thank you for any help!
0 Kudos
TimP
Honored Contributor III
404 Views

You must include the blas95 interfaces in your source. Without interfaces, you are calling the f77 interface with no checking, so you are calling the f77 sdot with no length argument. The blas95 interfaces fix it up by using size intrinsic to pass the length, and they make your invocation of the dot function refer to the appropriate f77 function, according to the data type of your arguments.

sdot would still be a direct call to the old style interface, and would not be checked unless you included the corresponding USE file.

In the examples directory, there is an example ddotx.f90of double precision usage. You might try that, then make a single precision version of it. Note the USE lines, setting working precision to double (in the example case) and invoking the mklblas_95 interfaces.

0 Kudos
Tabrez_Ali
Beginner
404 Views
Use the mkl95_blas module and then compile with ...

-I/opt/intel/mkl/include -L/opt/intel/mkl/lib/32/ -lmkl_blas95 -lmkl

program test
use mkl95_blas
.
.
.
end program test


Make sure that the include path contains the needed modules (mkl95_blas.mod, mkl95_precision.mod etc.)
0 Kudos
alexism
Beginner
404 Views
Thank you for the replies. I finally got it to work (I had to copy the libmkl_blas95.a file to the /lib/32 folder). Is the -I/opt/intel/mkl/include necessary? It works without this option.

One more question: when I built the mkl interface, does it make a difference if I compile with optimizations (like the -fast switch). It shoudln't right?

Once again, thank you very much for helping,

sincerely,

Alexis
0 Kudos
Tabrez_Ali
Beginner
404 Views
No it should not as you are only building the interface.
0 Kudos
alexism
Beginner
404 Views
That's what I thought. Now I'm ready to use intel MKL, except that my automatic makefile generator script doesn't seem to work anymore (I was using a perl script called fmkmf). Does anyone know of another good one that will work to make makefiles with intel MKL?
0 Kudos
Reply