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

Fortran Lapack Access Violation

usachemo
Beginner
762 Views
I am trying to write a simple matrix inversion program that takes a 3x3 matrix and inverts using sgetrf and sgetri. Below is my code:

Program InverterTest
Use lapack95, Only: getrf, getri

Implicit None

Real:: a(3,3)
Integer:: ipiv(1,3)
Integer:: i,j

a(1,:) = [1,3,5]
a(2,:) = [4,2,6]
a(3,:) = [9,4,1]
Print *, a

Call sgetrf(a,ipiv)
Print *, a
Call sgetri(a,ipiv)
Print *, a

End Program InverterTest

Using VS2008 I have tried to follow all of the instructions to insure that all the libraries and include files are in the right place. The program compiles just fine and runs, but when it tries to call sgetrf it crashes and gives:

forrtl: severe (157): Program exception - access violation

Any ideas? Thanks in advance.

Mike
0 Kudos
2 Replies
TimP
Honored Contributor III
762 Views
You can't use lapack95 argument list in direct calls to the f77 entry points. Of course, when you get that part right, it will complain that there are no specific subroutines to match ipiv with 2 subscripts where 1 is required (although that's only a cleanliness issue).
I trust you had already solved the problem that the lapack95.mod files aren't in the top level mklinclude folder where the compiler setup is looking for them (either by adding your own -I or by copying them, or by adding the folder in ifortvarsxx.bat or Fortran properties).
0 Kudos
Vladimir_Koldakov__I
New Contributor III
762 Views

Hi Mike,

Really, to call lapack95 interface you should use generic names and appropriate parameters:


Integer
:: ipiv(3)
Callgetrf(a,ipiv)
Call getri(a,ipiv)

Otherwise you call lapack77 routine directly with insufficient parameters.


Thanks,
Vladimir

0 Kudos
Reply