I am trying to use the ARPACK library written in fortran to solve an eigenvalue problem from within a C++ program, together with MKL implementations of the required BLAS and LAPACK routines. Specifically, I need to use the ARPACK driver for a standard eigenvalue problem of a complex general matrix. One first calls the ARPACK routine znaupd, which does the Arnoldi iteration, and then zneupd to extract the eigenvalues and -vectors. The sample program I have written is in C++ and calls the routines znaupd and zneupd as external fortran routines. The program runs perfectly fine when I link against regular BLAS/LAPACK (from the Ubuntu repos in my case) or OpenBLAS, but doesn't work with MKL.
The problem I am facing is that if I link against MKL, the program either gets stuck in an infinite loop or crashes during the ARPACK routine zneupd when requesting eigenvectors to be calculated as well.
I have pinpointed the problem to a call to the BLAS routine zdotc. When linked against MKL, mkl_blas_avx_zdotc is actually called and this routine seems to modify memory where it shouldn't. Specifically in this case, it also modifies a for-loop counter and always resets it to 0 and the program is infinitely stuck in this loop (If of interest, the loop is in ARPACK's file zneupd.f from line 719 to 736, the affected loop variable is j). Sometimes mkl_blas_avx_zdotc seems to modify memory somewhere else too and the program segfaults.
I tried linking against a precompiled version of ARPACK from the Ubuntu repos, as well as against a self-built version downloaded from arpack-ng (http://forge.scilab.org/index.php/p/arpack-ng/) that I built using gfortran. The problem is the same in both cases.
I compile my program using
icpc -std=c++11 -g -c arpack_test.cpp -o arpack_test.o
When I link against MKL, I follow the MKL link line advisor and use
icpc -o arp_test arpack_test.o /path/to/arpack/static/libarpack_debug.a -L${MKLROOT}/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -lm -lgfortran
Is there anything specific I need to watch out for when using MKL together with gfortran compiled libraries? To check if the problem is connected to passing complex c style arrays to fortran, I implemented the C++ program entirely using double c-style arrays only. Apart from that, is there anything one should watch out when using MKL in this case?
Thanks,
Valentin