0

I'm trying to write a program that is going to use both Arpack-ng and MKL routines. I was testing the behavior by running a simple code which use a single call to the function dsaupd, which should return ido=-1 and info = 0, but it actually returned ido = 99 and info=4294967286.

This is the Arpack-ng build summary:

-- Configuration summary for arpack-ng-3.9.0:
   -- prefix: /usr/local
   -- MPI: OFF (ICB provided )
   -- ICB: ON
   -- INTERFACE64: 0
   -- FC:      /opt/intel/oneapi/compiler/2023.1.0/linux/bin/intel64/ifort
   -- FCFLAGS: -O3 
   -- CC:      /usr/bin/cc
   -- CCFLAGS: -O3 -DNDEBUG 
   -- CXX:      /usr/bin/c++
   -- CXXFLAGS: -O3 -DNDEBUG 
   -- BLAS:
      -- link:    /opt/intel/oneapi/mkl/2023.1.0/lib/intel64/libmkl_intel_lp64.so
      -- link:    /opt/intel/oneapi/mkl/2023.1.0/lib/intel64/libmkl_intel_thread.so
      -- link:    /opt/intel/oneapi/mkl/2023.1.0/lib/intel64/libmkl_core.so
      -- link:    /opt/intel/oneapi/compiler/2023.1.0/linux/compiler/lib/intel64_lin/libiomp5.so
      -- link:    -lm
      -- link:    -ldl
   -- LAPACK:
      -- link:    /opt/intel/oneapi/mkl/2023.1.0/lib/intel64/libmkl_intel_lp64.so
      -- link:    /opt/intel/oneapi/mkl/2023.1.0/lib/intel64/libmkl_intel_thread.so
      -- link:    /opt/intel/oneapi/mkl/2023.1.0/lib/intel64/libmkl_core.so
      -- link:    /opt/intel/oneapi/compiler/2023.1.0/linux/compiler/lib/intel64_lin/libiomp5.so
      -- link:    -lm
      -- link:    -ldl
      -- link:    -lm
      -- link:    -ldl

This is the code I'm running:

program dsaupd_mkl
    implicit none
    integer, parameter :: n=3, ldv=n, ncv = n
    integer :: ido, nev, iparam(11), ipntr(11), lworkl, info
    real(8) :: tol, resid(n), v(ldv,ncv), workd(3*n), workl(ncv*(ncv+8))
    character ::bmat(1)

    integer :: ishfts, maxitr, mode1

    external :: dsaupd

    ido = 0
    bmat = 'I'
    nev = 1
    tol = 0.d0
    
    ishfts = 1
    maxitr = 1000
    mode1 = 1
    !
    iparam(1) = ishfts
    !
    iparam(3) = maxitr
    !
    iparam(7) = mode1

    lworkl = ncv*(ncv+8)
    info = 0
    print*, 'iparam= ', iparam
    print*, ''

    call dsaupd( ido, bmat, n, 'SA', nev, tol, resid, ncv, v, ldv, iparam, ipntr, workd, workl,&
            lworkl, info )
    print*, ido, info
end program dsaupd_mkl


And last the compiling line

ifort -I"${MKLROOT}/include" -w _results/$(FILENAME).o -o _results/$(FILENAME) -L${MKLROOT}/lib/intel64 -larpack -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm -ldl 

By inserting some prints in dsaupd.f, I figure out that actually info was equal to -10, while the value returned to the main program was 2**32-10, as if the info variable in the main is an unsigned int, even though it was not declared as such. Furthermore the info=-10 was related to the fact that the array indexes have been shifted:

  • main/iparam(1) -> dsaupd/iparam(1)
  • main/iparam(2) -> dsaupd/iparam(3)
  • main/iparam(3) -> dsaupd/iparam(5) And so on.

Such problem happens only with the integer arrays (iparam and ipntr), while it does not happen for the arrays of reals (I tried with resid).

I don't know if there is something wrong in the building options of Arpack-ng or in the compiling options, or even worse, it is a package problem.

1 Answer 1

0

What was happening is that the main program was using 8 bytes integers, while the Arpack Routine was using 4 bytes. I didn't realize that was the mistake cause I already tried to build Arpack with ILP64 interface, but I did not realize that cmake was always linking libmkl_intel_lp64 instead of libmkl_intel_ilp64. What was missing was the following line:

cmake -D BLA_VENDOR=Intel10_64ilp
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.