Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
55 Views

Gfortran compiler linking help LAPACK95

Dear Mr. / Mrs. ,

I'm having difficulty compiling code that uses the DGETRF and DGETRI Fortran functions.
Below I placed a very small test example "test.f03", that illustrates my problem:

program main
use lapack95, only: DGETRF_F95

implicit none

integer :: i,j,info
integer, dimension(20) :: ipiv
real(8), dimension(20,20) :: test1,inverse1

do i=1,20
  test1(i,:) = (/ (j,j=i,19+i) /)
end do
inverse1 = test1
call DGETRF_F95(inverse1,ipiv,info)

if (info /= 0) then
  stop 'Matrix is numerically singular'
end if

end program main

When I attempt to compile this code I get the following errors:

bash-4.3$ gfortran test.f03 -I./include -L/opt/sw/intel/mkl/lib/intel64 -lmkl_lapack95_lp64 -lmkl_rt
/opt/sw/intel/mkl/lib/intel64/libmkl_lapack95_lp64.a(dgetrf.o): In function `dgetrf_f95_':
../../../../interfaces/lapack95/source/dgetrf.f90:(.text+0xa76): undefined reference to `for_dealloc_allocatable'
../../../../interfaces/lapack95/source/dgetrf.f90:(.text+0xb46): undefined reference to `for_check_mult_overflow64'
../../../../interfaces/lapack95/source/dgetrf.f90:(.text+0xb63): undefined reference to `for_allocate'
../../../../interfaces/lapack95/source/dgetrf.f90:(.text+0xbc8): undefined reference to `for_check_mult_overflow64'
collect2: error: ld returned 1 exit status

Which is completely unknown to me. Could somebody tell me what I'm missing here?

Thank you for your time!

 

0 Kudos
4 Replies
Highlighted
Black Belt
55 Views

Please follow the on-line advice: https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor

You require at least the mkl core and a choice of lp or ilp and sequential or thread (according to your choice of openmp) libraries, besides the f95 wrapper library (which is best used to support documented blas95 and lapack95 calls).

0 Kudos
Highlighted
Beginner
55 Views

Dear Tim, thanks for your response!

I followed the on-line advice (11.2 MKL Linux, GNU Fortran, Intel 64, Static, LP64, Sequential LAPACK95),
and nothing seems to have changed in the results of the compiler call.

export F95ROOT=/opt/sw/intel/mkl
export MKLROOT=/opt/sw/intel/mkl
gfortran test.f03 $F95ROOT/lib/intel64/libmkl_lapack95_lp64.a -Wl,--start-group $MKLROOT/lib/intel64/libmkl_gf_lp64.a $MKLROOT/lib/intel64/libmkl_core.a $MKLROOT/lib/intel64/libmkl_sequential.a -Wl,--end-group -lpthread -lm -ldl -I./include -m64 -I$F95ROOT/include

/opt/sw/intel/mkl/lib/intel64/libmkl_lapack95_lp64.a(dgetrf.o): In function `dgetrf_f95_':
../../../../interfaces/lapack95/source/dgetrf.f90:(.text+0xa76): undefined reference to `for_dealloc_allocatable'
../../../../interfaces/lapack95/source/dgetrf.f90:(.text+0xb46): undefined reference to `for_check_mult_overflow64'
../../../../interfaces/lapack95/source/dgetrf.f90:(.text+0xb63): undefined reference to `for_allocate'
../../../../interfaces/lapack95/source/dgetrf.f90:(.text+0xbc8): undefined reference to `for_check_mult_overflow64'
collect2: error: ld returned 1 exit status

I am not entirely sure what you mean by f95 wrapper library and can't find any relevant google results.
Can you explain what you mean by this, or do you have any further suggestions to fix resolve the original issue?

0 Kudos
Highlighted
Black Belt
55 Views

For example, getrf is a documented supported function call with plenty of references on line.  You may have chosen an undocumented entry point which relies on ifort support libraries.   dgetrf is a documented call which doesn't depend on lapack95 (and is specialized to double precision) but ought to include gfortran compatible implementation.

 

0 Kudos
Highlighted
Beginner
55 Views

Thank you for your suggestions,

On the page of the Link Line Advisor I found the line:

Set the F95ROOT variable. Fortran 95 interfaces are compiler-dependent. The
Fortran 95 interfaces and wrappers are delivered as sources, build the
appropriate library and modules with your
compiler. Please see also the Intel(R) MKL User
Guide.

Apparently one has to "make" a locally compiled version of LAPACK. Once I did that and used the path as $F95ROOT, the program I provided above compiled and functioned just fine. This issue is now resolved.

0 Kudos