eigenvalues and eigenvectors using mkl lapack libraries in F

Open discussion regarding features, bugs, issues, vendors, etc.

eigenvalues and eigenvectors using mkl lapack libraries in F

Postby ricoamor » Wed Jul 06, 2011 3:54 am

I am trying to calculate the eigenvalues and eigenvectors of matrices of different sizes. I am using a piece of very simple Fortran90 code and I am compiling it linking to the appropriate Lapack libraries included in the Intel MKL package, available in my machine, which runs in Ubuntu. The code "matrix_diag_01.f90" is attached at the end of the message. The "random" module just includes the "ran" random number generator from Numerical Recipes. The code compiles well using

Code: Select all
ifort -I $(MKLPATH) -o matrix_diag_01 matrix_diag_01.f90
      random.f90 $(MKLPATH)libmkl_lapack95.a -Wl,--start-group 
      $(MKLPATH)libmkl_intel_lp64.a $(MKLPATH)libmkl_lapack.a
      $(MKLPATH)libmkl_intel_thread.a $(MKLPATH)libmkl_core.a
       -Wl,--end-group -lguide -lpthread

The executable works nicely when smallish matrices are given. However, for matrices of size 3000x3000 it produces some strange behaviour. First it gives this error

Code: Select all
MKL ERROR : Parameter 8 was incorrect on entry to SSYEVD

However, there are only 3 parameters in the call to SSYEVD. Second, it returns the eigenvectors but not the eigenvalues. I have checked by compiling in another machine with larger memory but the outcome was the same.

Can anyone please help?

Thanks!

Code: Select all
PROGRAM matrix_diag_01

USE random

IMPLICIT NONE

INTERFACE
   SUBROUTINE diag(mat,n)
      INTEGER n
      REAL,DIMENSION(n,n) :: mat
   END SUBROUTINE
END INTERFACE

INTEGER n,i,j,iseed
REAL, DIMENSION(:), ALLOCATABLE  :: w
REAL, DIMENSION(:,:), ALLOCATABLE :: mat

write (*,*) ' Please enter size of matrix'
read (*,*) n
write (*,*) ' Please type seed'
read (*,*) iseed

allocate (mat(n,n))

do i = 1,n
   do j = 1,n
      mat(i,j) = ran(iseed)
   end do
end do

call diag(mat,n)

stop
END
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SUBROUTINE diag(mat,n)

  USE mkl95_lapack
  USE mkl95_precision

  IMPLICIT NONE

  CHARACTER(len=1) :: jobz = 'V'

  INTEGER n,i

  REAL,DIMENSION(n,n) :: mat
  REAL,DIMENSION(:,:),ALLOCATABLE :: matt,a
  REAL,DIMENSION(:),ALLOCATABLE :: w

  allocate (matt(n,n),a(n,n),w(n))

  matt = mat*transpose(mat)
  a = sqrt(matt)
  open (unit=7,file="matrix.dat",status="unknown")
  do i = 1,n
     write (7,100) a(i,:)
  end do
  close (unit=7)

  call syevd(a,w,jobz)

  open (unit=8,file="eig_val.dat",status="unknown")
  do i = 1,n
     write (8,100) w(i)
  end do
  close (unit=8)

  open (unit=9,file="eig_vec.dat",status="unknown")
  do i = 1,n
     write (9,100) a(i,:)
  end do
  close (unit=9)

  return
 100 format(5000f16.5)
end
ricoamor
 
Posts: 2
Joined: Wed Jul 06, 2011 3:47 am

Re: eigenvalues and eigenvectors using mkl lapack libraries

Postby Sidio47 » Thu Jul 07, 2011 2:37 pm

Have you checked your stack size? If your matrices are taking up more memory than your default stack then you can run into some weird errors; typically segmentation faults but not always.
Sidio47
 
Posts: 3
Joined: Wed Jul 06, 2011 2:05 pm

Re: eigenvalues and eigenvectors using mkl lapack libraries

Postby Julien Langou » Thu Jul 07, 2011 2:48 pm

You are using the syevd subroutines from LAPACK95 supported by MKL.
Not an expert with this interface on my end. Maybe contact MKL folks directly.
Julien.
Julien Langou
 
Posts: 734
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Re: eigenvalues and eigenvectors using mkl lapack libraries

Postby nmozarto » Wed Jul 27, 2011 12:52 am

Thank you. It really looks like a problem in Fortran95 interfaces.
I'll try to investigate it. You should post this problem on Intel MKL forum.
nmozarto
 
Posts: 5
Joined: Thu Jan 20, 2011 1:05 am
Location: Intel


Return to User Discussion

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 3 guests