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

error LNK2019: unresolved external symbol DGETRF_MKL95 referenced in function SUPORTBASE_mp_INVMAT

Radek_Z_
Beginner
1,569 Views

I inherited some project done in Fortran 95. After upgrade from Intel Fotran Composer v2013 to v2016, I am receiving errors during linking:

1>suportbase.obj : error LNK2019: unresolved external symbol DGETRF_MKL95 referenced in function SUPORTBASE_mp_INVMAT

1>suportbase.obj : error LNK2019: unresolved external symbol DGETRI_MKL95 referenced in function SUPORTBASE_mp_INVMAT

...fatal error LNK1120: 2 unresolved externals

The code which cause the problem:

pure function invmat(a) result(b)
USE usedlapck95_mod, ONLY: getrf,getri
USE, INTRINSIC :: IEEE_ARITHMETIC
implicit none


    real(8),intent(in),dimension(:,:) :: a
    real(8),dimension(size(a,1),size(a,1)) :: b


    integer(4),dimension(size(a,1)) :: ipiv
    integer(4) :: info

    b=a

    if (size(a,1)==0) return

    call getrf(b,ipiv,info)

    call getri(b,ipiv,info)

    if (info>0) b=IEEE_VALUE (b,IEEE_POSITIVE_INF)


end function

The code produce inverse matrix and it uses MKL library rutines.

The module which is called is:

MODULE F95_PRECISION
    INTEGER, PARAMETER :: SP = KIND(1.0E0)
    INTEGER, PARAMETER :: DP = KIND(1.0D0)
END MODULE F95_PRECISION

MODULE usedlapck95_mod

INTERFACE GETRF
    PURE SUBROUTINE SGETRF_MKL95(A,IPIV,INFO)
        ! MKL 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_MKL95
    PURE SUBROUTINE DGETRF_MKL95(A,IPIV,INFO)
        ! MKL 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_MKL95
    PURE SUBROUTINE CGETRF_MKL95(A,IPIV,INFO)
        ! MKL 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_MKL95
    PURE SUBROUTINE ZGETRF_MKL95(A,IPIV,INFO)
        ! MKL 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_MKL95
END INTERFACE GETRF

INTERFACE GETRI
    PURE SUBROUTINE SGETRI_MKL95(A,IPIV,INFO)
        ! MKL Fortran77 call:
        ! SGETRI(N,A,LDA,IPIV,WORK,LWORK,INFO)
        USE F95_PRECISION, ONLY: WP => SP
        INTEGER, INTENT(OUT), OPTIONAL :: INFO
        REAL(WP), INTENT(INOUT) :: A(:,:)
        INTEGER, INTENT(IN) :: IPIV(:)
    END SUBROUTINE SGETRI_MKL95
    PURE SUBROUTINE DGETRI_MKL95(A,IPIV,INFO)
        ! MKL Fortran77 call:
        ! DGETRI(N,A,LDA,IPIV,WORK,LWORK,INFO)
        USE F95_PRECISION, ONLY: WP => DP
        INTEGER, INTENT(OUT), OPTIONAL :: INFO
        REAL(WP), INTENT(INOUT) :: A(:,:)
        INTEGER, INTENT(IN) :: IPIV(:)
    END SUBROUTINE DGETRI_MKL95
    PURE SUBROUTINE CGETRI_MKL95(A,IPIV,INFO)
        ! MKL Fortran77 call:
        ! CGETRI(N,A,LDA,IPIV,WORK,LWORK,INFO)
        USE F95_PRECISION, ONLY: WP => SP
        INTEGER, INTENT(OUT), OPTIONAL :: INFO
        COMPLEX(WP), INTENT(INOUT) :: A(:,:)
        INTEGER, INTENT(IN) :: IPIV(:)
    END SUBROUTINE CGETRI_MKL95
    PURE SUBROUTINE ZGETRI_MKL95(A,IPIV,INFO)
        ! MKL Fortran77 call:
        ! ZGETRI(N,A,LDA,IPIV,WORK,LWORK,INFO)
        USE F95_PRECISION, ONLY: WP => DP
        INTEGER, INTENT(OUT), OPTIONAL :: INFO
        COMPLEX(WP), INTENT(INOUT) :: A(:,:)
        INTEGER, INTENT(IN) :: IPIV(:)
    END SUBROUTINE ZGETRI_MKL95
END INTERFACE GETRI

INTERFACE SYEVD
        ! JOBZ='N','V'; default: 'N'
        ! UPLO='U','L'; default: 'U'
    PURE SUBROUTINE SSYEVD_F95(A,W,JOBZ,UPLO,INFO)
        ! Fortran77 call:
        ! SSYEVD(JOBZ,UPLO,N,A,LDA,W,WORK,LWORK,IWORK,LIWORK,INFO)
        USE F95_PRECISION, ONLY: WP => SP
        CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: JOBZ
        CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
        INTEGER, INTENT(OUT), OPTIONAL :: INFO
        REAL(WP), INTENT(INOUT) :: A(:,:)
        REAL(WP), INTENT(OUT) :: W(:)
    END SUBROUTINE SSYEVD_F95
    PURE SUBROUTINE DSYEVD_F95(A,W,JOBZ,UPLO,INFO)
        ! Fortran77 call:
        ! DSYEVD(JOBZ,UPLO,N,A,LDA,W,WORK,LWORK,IWORK,LIWORK,INFO)
        USE F95_PRECISION, ONLY: WP => DP
        CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: JOBZ
        CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
        INTEGER, INTENT(OUT), OPTIONAL :: INFO
        REAL(WP), INTENT(INOUT) :: A(:,:)
        REAL(WP), INTENT(OUT) :: W(:)
    END SUBROUTINE DSYEVD_F95
END INTERFACE SYEVD

end module

Does anybody has an idea how to fix the problem with linker? I have "light" experience with Fortran so far, my colleagues do but they don't have any idea too.

Thank!

0 Kudos
2 Replies
mecej4
Honored Contributor III
1,569 Views

Some module and library names were changed in recent versions of MKL. What you need with IFort 16 is

      USE f95_precision, ONLY: WP => DP
      USE lapack95, ONLY: GETRF, GETRI

in the subprogram source from which GETRF and GETRI are called, and you need to add the appropriate Lapack95 library to the linker line. The library file to use is mkl_lapack95.lib for 32-bit targets, and mkl_lapack95_lp64.lib (if passing 4-byte integer arguments) or mkl_lapack95_ilp64.lib (if passing 8-byte integer arguments) for 64-bit targets.

There is no need to use your own module source (usedlapck95_mod).

0 Kudos
Radek_Z_
Beginner
1,569 Views

Thank you! That solved my problem! :-)
 

0 Kudos
Reply