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

begginer introduction to LAPACK

ebarbero
Beginner
462 Views
I am a begginer user of Intel Fortran 11.1 wrapped with Visual Studio 2008. I need to use LAPACK routines. I have read the documentation for hours and I can't figure it out. What do I need to do to get this code to work?

program minverse

! Intel Fortran 11.1.048

! Visual Studio 2008, Debug, Win32

use lapack95

use f95_precision

integer ipiv(3)

double precision a(3,3)

a = 0.d0;

a(1,1) = 1.

a(2,2) = 1.

a(3,3) = 1.

call getrf( a ,ipiv)

call getri( a, ipiv)

write(*,'(3g15.5)') a

pause

end



Error 1 error LNK2019: unresolved external symbol _DGETRF_F95 referenced in function _MAIN__ minverse.obj
Error 2 error LNK2019: unresolved external symbol _DGETRI referenced in function _MAIN__ minverse.obj
0 Kudos
7 Replies
mecej4
Honored Contributor III
462 Views
When compiling a program that requires additional libraries, you need to tell the compiler to link those libraries.

With some earlier versions of IFort, you had to build MKL_LAPACK95.LIB from sources, and place the resulting library in a path accessible through the LIB environmental variable or through a specification in VisualStudio. However, since the compiler did not complain about not finding the Lapack95 module files, one gathers that the library has been built already.

The command

ifort /Qmkl MAIN_minverse.f90 mkl_lapack95.lib

should build the .EXE file.

0 Kudos
Gennady_F_Intel
Moderator
462 Views
That's not completely correct. Please don't forget to add others mkl's librairies like -mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib. Please see the Linker Adviser suggestion.
0 Kudos
mecej4
Honored Contributor III
462 Views
Gennady, the /Qmkl compiler option in Windows causes the compiler driver "ifort" to add the following line (among a long list of others) to the call to "fortcom"

[bash]-mP3OPT_defaultlibs_list=mkl_intel_c_dll,mkl_intel_thread_dll,mkl_core_dll,libiomp5md 
[/bash]

as can be ascertained by using the "/#" option.

This convenient feature has been available with Intel Fortran 11 onwards, perhaps with even earlier edition, and makes it unnecessary to use the Link Line Advisor for simple programs that use the default options to call MKL.
0 Kudos
ebarbero
Beginner
462 Views
I am using visual studio to produce a console app, I chose mode Debug, Win32, and belowis what I did to configure VS:

visual studio, project, properties

fortran, general, additional include directories: c:\program files (x86)\intel\compiler\11.1\048\mkl\include\ia32\

linker, general, additional library directives: c:\program files (x86)\intel\compiler\11.1\048\mkl\ia32\lib

linker, input, additional dependencies: mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib


I get this error: The program '[4496] inverse.exe: Native' has exited with code -1073741701 (0xc000007b).
It crashes. It does not even type the matrix on the console.

This is my code:

program inverse
use lapack95
use f95_precision
implicit none
integer ipvt(3)
double precision A(3,3)
call random_number(A)
print *, A
call dgetrf(A,ipvt)
pause
end program inverse


... can you tell me what might be wrong???
0 Kudos
Gennady_F_Intel
Moderator
462 Views
ahh, yes, sure. Isimplyoverlookedthisoption on the command line.
0 Kudos
mecej4
Honored Contributor III
462 Views
Please ignore. I have had problems with the Intel Web server giving 504 errors and this was a duplicate post..
0 Kudos
mecej4
Honored Contributor III
462 Views
If you intend to use the Fortran 95 interface, the subroutine name to call is getrf, not dgetrf.

You can get the compiler to catch such errors by adding

INCLUDE 'MKL_LAPACK.FI'

when your source code is in fixed format.

Calling the F77 function dgetrf with only two arguments will fail, since the remaining required arguments and those that are not in the proper order are going to be undefined items pulled off the stack.
0 Kudos
Reply