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

linking to LAPACK95 problem

John_Inglesfield
Beginner
1,030 Views

I have just installed the Intel Fortran compiler + MKL etc on my Mac (with Intel Core Duo), and had no difficulty getting my codes with Lapack subroutines to run. But I want to move to Lapack95, and I cannot get this to work! The small fortran test program I've been using is

program main
use lapack95, only:getrf
implicit none
integer::info
integer,parameter::knd=selected_real_kind(12)
real(knd)::a(2,2)
a=1.0
call getrf(a,info)
end program main

and I have tried to run it from the command line

ifort -L$MKLROOT/lib/em64t -I$MKLROOT/include/em64t/lp64 -lmkl_lapack95 -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread main.f90

The file lapack95.mod is in the directory $MKLROOT/include/em64t/lp64, and the file -lmkl_lapack95_lp64.a is in $MKLROOT/lib/em64t.

The error message I obtain is:

error #6285: There is no matching specific subroutine for this generic subroutine call. [GETRF]

I wonder what I am doing wrong in the command line or in the program?

John E.I.

0 Kudos
1 Solution
barragan_villanueva_
Valued Contributor I
1,030 Views

Hi,

GETRF has three arguments:

INTERFACE GETRF
PURE SUBROUTINE SGETRF_F95(A,IPIV,INFO)
! Fortran77 call:
! SGETRF(M,N,A,LDA,IPIV,INFO)
USE F95_PRECISION, ONLY: WP => SP
INTEGER, INTENT(OUT), OPTIONAL :: INFO
REAL(WP), INTENT(INOUT) :: A(:,:)
INTEGER, INTENT(OUT), OPTIONAL, TARGET :: IPIV(:)
END SUBROUTINE SGETRF_F95
PURE SUBROUTINE DGETRF_F95(A,IPIV,INFO)
! Fortran77 call:
! DGETRF(M,N,A,LDA,IPIV,INFO)
USE F95_PRECISION, ONLY: WP => DP
INTEGER, INTENT(OUT), OPTIONAL :: INFO
REAL(WP), INTENT(INOUT) :: A(:,:)
INTEGER, INTENT(OUT), OPTIONAL, TARGET :: IPIV(:)
END SUBROUTINE DGETRF_F95
PURE SUBROUTINE CGETRF_F95(A,IPIV,INFO)
! Fortran77 call:
! CGETRF(M,N,A,LDA,IPIV,INFO)
USE F95_PRECISION, ONLY: WP => SP
INTEGER, INTENT(OUT), OPTIONAL :: INFO
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
INTEGER, INTENT(OUT), OPTIONAL, TARGET :: IPIV(:)
END SUBROUTINE CGETRF_F95
PURE SUBROUTINE ZGETRF_F95(A,IPIV,INFO)
! Fortran77 call:
! ZGETRF(M,N,A,LDA,IPIV,INFO)
USE F95_PRECISION, ONLY: WP => DP
INTEGER, INTENT(OUT), OPTIONAL :: INFO
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
INTEGER, INTENT(OUT), OPTIONAL, TARGET :: IPIV(:)
END SUBROUTINE ZGETRF_F95
END INTERFACE GETRF

So, please defineIPIV in main.f90 and addit as the second argument for GETRF.

Try your source file main.f90 before libraries (deleted junk there)

ifort main.f90 -L$MKLROOT/lib/em64t -I$MKLROOT/include/em64t/lp64 -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread

View solution in original post

0 Kudos
5 Replies
barragan_villanueva_
Valued Contributor I
1,031 Views

Hi,

GETRF has three arguments:

INTERFACE GETRF
PURE SUBROUTINE SGETRF_F95(A,IPIV,INFO)
! Fortran77 call:
! SGETRF(M,N,A,LDA,IPIV,INFO)
USE F95_PRECISION, ONLY: WP => SP
INTEGER, INTENT(OUT), OPTIONAL :: INFO
REAL(WP), INTENT(INOUT) :: A(:,:)
INTEGER, INTENT(OUT), OPTIONAL, TARGET :: IPIV(:)
END SUBROUTINE SGETRF_F95
PURE SUBROUTINE DGETRF_F95(A,IPIV,INFO)
! Fortran77 call:
! DGETRF(M,N,A,LDA,IPIV,INFO)
USE F95_PRECISION, ONLY: WP => DP
INTEGER, INTENT(OUT), OPTIONAL :: INFO
REAL(WP), INTENT(INOUT) :: A(:,:)
INTEGER, INTENT(OUT), OPTIONAL, TARGET :: IPIV(:)
END SUBROUTINE DGETRF_F95
PURE SUBROUTINE CGETRF_F95(A,IPIV,INFO)
! Fortran77 call:
! CGETRF(M,N,A,LDA,IPIV,INFO)
USE F95_PRECISION, ONLY: WP => SP
INTEGER, INTENT(OUT), OPTIONAL :: INFO
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
INTEGER, INTENT(OUT), OPTIONAL, TARGET :: IPIV(:)
END SUBROUTINE CGETRF_F95
PURE SUBROUTINE ZGETRF_F95(A,IPIV,INFO)
! Fortran77 call:
! ZGETRF(M,N,A,LDA,IPIV,INFO)
USE F95_PRECISION, ONLY: WP => DP
INTEGER, INTENT(OUT), OPTIONAL :: INFO
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
INTEGER, INTENT(OUT), OPTIONAL, TARGET :: IPIV(:)
END SUBROUTINE ZGETRF_F95
END INTERFACE GETRF

So, please defineIPIV in main.f90 and addit as the second argument for GETRF.

Try your source file main.f90 before libraries (deleted junk there)

ifort main.f90 -L$MKLROOT/lib/em64t -I$MKLROOT/include/em64t/lp64 -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread

0 Kudos
barragan_villanueva_
Valued Contributor I
1,030 Views

Just look at the corrected example and its output:

program main
use lapack95, only:getrf
implicit none
integer::info
integer,parameter::knd=selected_real_kind(12)
real(knd)::a(2,2)
integer::i(2)
a=1.0
print *,'a=',a
call getrf(a,i,info)
print *,'info=',info
print *,'a=',a
print *,'i=',i
end program main

and

% ./a.out
a= 1.00000000000000 1.00000000000000 1.00000000000000
1.00000000000000
info= 2
a= 1.00000000000000 1.00000000000000 1.00000000000000
0.000000000000000E+000
i= 1 2

0 Kudos
John_Inglesfield
Beginner
1,030 Views

Many thanks Victor for the corrections to the arguments of getrf, and for getting rid of junk in the command line. I'm delighted to be able to use Lapack95!

John

0 Kudos
Vithaya_R_
Beginner
1,030 Views

 

 Dear Victor Pasko

Could you please recommend me on the command line to compile program to use lapack95 for GETRF using the intel MKL 11.3. As I used the command  "ifort axb.f90 -L$MKLROOT/lib/intel64 -I$MKLROOT/include/intel64/lp64  -l$MKLROOT/lib/intel64_lin/libmkl_intel_lp64 -llibmkl_intel_thread -llibmkl_core -llibiomp5 -llibpthread", I got an error as "ld: cannot find -llibmkl_lapack95_lp64". I have tried to correct it but I could not get success.

Thank you very much for your kind helps,

Vithaya 

0 Kudos
mecej4
Honored Contributor III
1,030 Views

There are several errors in your command line, and the command options you showed could not have attempted to use the Lapack95 library. The linker ld adds "lib" as a prefix and ".so" or ".a" as a suffix to the library names specified with the -l (lower case L, as in "lib") option.

Please use the MKL Link Line Advisor, which may be installed on your computer or is available at https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/ .

0 Kudos
Reply