Search code examples
fortranlapackintel-fortranintel-mkl

Segmentation fault during call to DPOSV routine from MKL 11.3 library


I am trying to run the following code, compiling with IFORT 2016, linking MKL 11.3 library:

program bug
  implicit none
  INCLUDE 'mkl.fi'
  integer*4, parameter :: Npart=25
  real(kind=8) :: u(1:Npart), lapackab(1:Npart,1:Npart)
  integer*4 :: i

  u=0.2d0
  lapackab=0d0
  do i=1,Npart
      lapackab(i,i)=2d0
  enddo

  call DPOSV('L',Npart,1,lapackab,Npart,u,Npart,i)
  write(*,*) "i=",i
end program

using the following command:

ifort -O0 -g -openmp -o file.o -c file.f90 -I/opt/share/INTEL/mkl/include
ifort -O0 -g -openmp file.o -o run -L/opt/share/INTEL/mkl/lib/  -I/opt/share/INTEL/mkl/include  -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm -ldl

for some obscure reason, the code segfaults during the DPOSV. I have no idea why. Seriously, even Valgrind does not report anything weird.. Is there anybody that had the same issue with this particular routine?

EDIT: the code works perfectly with LAPACK 3.6.1 but not with MKL 11.3. I sent a post on the Intel Support forum, but it still has to be approved by moderators..


Solution

  • You are linking the ILP64 version of MKL but that one is used for 64-bit integers. You are using integer*4 so your integers are 32-bit (and the default integers as well). Use the MKL link advisor to link MKL correctly. You likely need the LP64 version.