# MKL library

## MKL library

I am very new to MKL, I wanted to solve a linear system using "getrs" command in Intel Fortran 11.1 running in windows 7 (64 bit). Please let me know how I can do it.

Thanks

15 posts / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.

Read the MKL documentation, and look through some of the example source codes. In fact, in the IFort 12.x and MKL 10.3 distribution there are examples of using subroutines sgetrs and dgetrs in the ...\mkl\examples\lapack\source directory.

Could you tell me where these examples are? I have been trying to link fortran 11.1 with MKL 10.1 but have not been successful yet. Could you please add more details on how to create a link btween intel fortran 11.1 abd MKL 10.1?

I cannot comment on older versions of IFort and MKL other than to say that older versions of MKL did come with plenty examples. Where they are installed depends on where you installed MKL. Below the location where MKL was installed you will find an "examples" sub-directory.

It is particularly simple to use the Lapack-95 interfaces. With some older versions of MKL, these interfaces were not provided in pre-built form, but one could use a supplied makefile to build them. Here is an example:

program linsolx

use lapack95, only : getrf, getrs

integer ipiv(3)
double precision :: a(3,3)=reshape([2.,-1.,0.,-1.,2.,-1.,0.,-1.,2.],[3,3])
double precision :: b(3) = ([4., 5., 6.])

call getrf( a ,ipiv)        ! Factorize A
call getrs( a, ipiv, b)     ! Solve A.x = b

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

end program linsolx


S:LANG> ifort /Qmkl getsX.f90 mkl_lapack95.lib


Could you tell me where these examples are? I have been trying to link fortran 11.1 with MKL 10.1 but have not been successful yet. Could you please add more details on how to create a link btween intel fortran 11.1 abd MKL 10.1?

please see here the KB article to find outwhich versions of the Intel IPP, Intel MKL and Intel TBB libraries are included as part of theIntel Compiler Probund les V11.* based

I want to use MKL library for IA 64 (Intel Fortran 11.1, MKL10.2 and Windows 7). What should I enter in input (Additional Dependencies) to be able to write "use lapack95"? and How can I find it out on my own for other functions of MKL?

(Let us not confuse IA64 and Intel64).

Add the paths corresponding to your installation and target architecture to the following configuration items in VS:

Project:Properties:Fortran:Libraries:Use Intel Math Kernel Library: Sequential (/Qmkl:sequential)

Note that I have installed the compiler in a different location than the default.

How do I know? I simply look for the directory where the file lapack95.mod (the module that you want to USE) exists, since the compiler has to read module files to do its job. Likewise, I look for the directory where the MKL libraries exist since the linker needs to read the library files to build the application.

I wanted to rund the following code:

program Console1
USE mkl95_LAPACK , only : getrf, getrs

! Variables

! Body of Console1

integer ipiv(3)

double precision :: a(3,3)=reshape([2.,-1.,0.,-1.,2.,-1.,0.,-1.,2.],[3,3])

double precision :: b(3) = ([4., 5., 6.])

call getrf( a ,ipiv) ! Factorize A

call getrs( a, ipiv, b) ! Solve A.x = b

print *, 'Hello World'

end program Console1

I have done the followings:

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

fortran, preprocessor, Preprocess Source File: Yes (/fpp)

When I try to compile this code, I get the following errors, please let me know what I need to do. Please write it in the simplest way as you can:

Error 1 error LNK2019: unresolved external symbol _DGETRF_MKL95 referenced in function _MAIN__ Console1.obj

Error 2 error LNK2019: unresolved external symbol _DGETRS1_MKL95 referenced in function _MAIN__ Console1.obj

Error 3 fatal error LNK1120: 2 unresolved externals Debug\Console1.exe

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

Do not mix 32-bit modules and 64-bit projects. The unresolved external symbols that you reported have the 32-bit decoration (leading underscore).

I have editted the following line to be:

fortran, general, additional include directories: C:\Program Files\Intel\MKL\10.2.7.040\include

I am still getting the same error. Could you please let me know why?

Please attach your build log file, which will help find out what went wrong. Or, display the linker command line -- it should have mkl_lapack95_lp64.lib as a library to link against.

PLease find attached the whole project files. It is a rar file.

## Attachments:

AttachmentSize
1.94 MB

As I suspected, you have mixed up 32-bit and 64-bit project dependencies.

You have only Win32 targets in your project file, but you have specified the MKL 64 bit libraries as additional dependencies for that target.

I suggest that you delete the messed up project files, and make a clean start again.

Here are the steps:

1. Create a new project, type console application. Add your source file to the project.

2. Choose the configuration as x64, debug.

3. Click Project => Properties => Fortran => Libraries, and elect to use MKL. Click "OK".

4. Click Project => Properties => Linker => Input => Additional Dependencies, and specify mkl_lapack95_lp64.lib. Click "OK".

5. Build

Thanks alot. I just changed the configuration to X64 in my project and every thing got fixed. One last questions: Can I use MKL and IMSL at the same time?

You can use any number of libraries, including MKL and IMSL, as appropriate.

Note that there is considerable overlap in functionality between MKL and IMSL, e.g., routines for computing eigenvalues. In such cases, note that the interfaces and arguments can be quite different. Furthermore, many routines modify input arguments; thus, if you want to use both, you may need to save and restore such arguments as required.