Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6975 Discussions

Problem with eigenvalues subroutine DSYGV, DSBGVD

GoldenRetriever
Beginner
448 Views
Hi there, I had problems with those subroutines, hope that someone can point out the reasons for these:
1. The problem could be run withgeneralized symmetric subroutineDSYGV inFORTRAN 77 syntax. However, I got "Access violation" error when usingFORTRAN 95 syntax. I dont know why.
2. For the same problem when I used the subroutine forbanded matricesDSBGVD, I could not get it work. It returned the value for INFO = 8. The same"Access violation" error when usingFORTRAN 95 syntax as previous case.
Please find attached for the sample code. The problem generated from example forD_GVCRG from IMSL so you might see that subroutine in the code as well.
Appreciated any advices and comments on this.
Sytem information:
Windows 7 Ultimate
Microsoft Visual Basic 2008
Intel Visual Fortran Compiler Professional Edition 11.1
Intel Math Kernel Library 10.3 Update 3 for Windows* OS
******************************************************************
[fortran]      INCLUDE 'link_fnl_static.h'
      !DEC$ OBJCOMMENT LIB:'libiomp5md.lib'
      USE IMSL_LIBRARIES
 
      IMPLICIT   NONE
      INTEGER    LDA, LDB, LDEVEC, N, KA, KB, LIWORK, LWORK, BLWORK, INFO
      PARAMETER  (N=4, LDA=N, LDB=N, LDEVEC=N, LIWORK=1, LWORK=3*N-1, BLWORK=3*N)
!
      INTEGER    I, NOUT
      DOUBLE PRECISION A(LDA,N), AB(LDA,N), B(LDB,N), BB(LDB,N), BETAV(N), PI, EIGENVALUES_VEC(N), W(N), DUMMY(1,1), WORK(LWORK), BWORK(BLWORK)
      COMPLEX *16    ALPHA(N), EVAL(N), EVEC(LDEVEC,N)
      INTEGER          IWORK(LIWORK)

!
!                                 Define values of A and B:
!                                 A = ( 0.24    0.39    0.42    0       )
!                                     ( 0.39    -0.11   0.39    0.63    )
!                                     ( 0.42	0.39	-0.25	0.48    )
!                                     ( 0       0.63	0.48	-0.03   )
!
!                                 B = ( 2.07	0.95	0	    0       )
!                                     ( 0.95	1.69	-0.29	0       )
!                                     ( 0	    -0.29	0.65	-0.33   )
!                                     ( 0	    0	    -0.33	1.17    )
!
!                                 Declare variables
      KA=2; KB=1
      DATA A/0.240D0,0.390D0,0.420D0,00D0, 0.390D0,-0.110D0,0.390D0,0.630D0, 0.420D0,0.390D0,-0.250D0,0.480D0, 00D0,0.630D0,0.480D0,-0.030D0/
      DATA B/2.070D0,0.950D0,00D0,00D0, 0.950D0,1.690D0,-0.290D0,00D0, 00D0,-0.290D0,0.650D0,-0.330D0, 00D0,00D0,-0.330D0,1.170D0/
!
      AB=A
      BB=B
      
!                                 Compute eigenvalues
      CALL D_GVCRG (A, B, ALPHA, BETAV, EVEC)
      CALL DSYGV(1,"N","U",N,A,N,B,N,EIGENVALUES_VEC,WORK,LWORK,INFO)
!      CALL DSYGV(A,B,EIGENVALUES_VEC)  !Fortran 95 Interface - NOT WORKING
      CALL DSBGVD('N',"U",N,KA,KB,AB,N,BB,N,W,DUMMY,1,BWORK,BLWORK,IWORK,LIWORK,INFO)   ! NOT WORKING
!      CALL DSBGVD(AB,BB,W)  !Fortran 95 Interface - NOT WORKING

      DO 10  I=1, N
            EVAL(I) = ALPHA(I)/BETAV(I)
   10 CONTINUE
!                                 Compute performance index
      PI = GPIRG(N,A,B,ALPHA,BETAV,EVEC)
!                                 Print results
      CALL UMACH (2, NOUT)
      CALL WRCRN ('EVAL', EVAL, 1, N, 1)
      CALL WRCRN ('EVEC', EVEC)
      WRITE (NOUT,'(/,A,F6.3)') ' Performance index = ', PI
!                                 Solve for reciprocals of values
      CALL D_GVCRG (B, A, ALPHA, BETAV, EVEC)
 
!                                 Compute reciprocals
      DO 20  I=1, N
            EVAL(I) = ALPHA(I)/BETAV(I)
   20 CONTINUE
!                                 Compute performance index
      PI = GPIRG(N,B,A,ALPHA,BETAV,EVEC)
!                                 Print results
      CALL WRCRN ('EVAL reciprocals', EVAL, 1, N, 1)
      CALL WRCRN ('EVEC', EVEC)
      WRITE (NOUT,'(/,A,F6.3)') ' Performance index = ', PI
      END[/fortran]
0 Kudos
4 Replies
mecej4
Honored Contributor III
448 Views
To use the Fortran 95 interfaces to MKL, you should add

USE MKL95_LAPACK

to subprograms that make calls to Lapack95 routines. To use abbreviated argument lists in such calls, you should call the interface names that have been defined with optional arguments. In your example, replace DSYGV by SYGV and DSBGVD by SBGVD in the statements that you marked "NOT WORKING".

Apart from the problems just covered, the test matrices that you use produce in the output this warning:

[bash] *** WARNING  ERROR 1 from DGPIRG.  The performance index =
 ***          2.117869187120076D+15.  A value greater than 100 is considered
 ***          poor.
[/bash]
You may have had similar errors in the band-solver version of your program that you allude to, but we need to see the example source code.
0 Kudos
GoldenRetriever
Beginner
448 Views
Thanks mecej4for your reply. Appreciated that.
You are right, I just realise now that theoptional arguments for Fortran 95 syntax must be used with SYGV (was mixed up with the way IMSL gives names for single and double precision)
I have made the changes like your suggestion but I still got the error. If using SYGV,the errors are:
Error 7 error LNK2019: unresolved external symbol _DSYGV_MKL95 referenced in function _MAIN__ dsgv-ex.obj
Error 8 fatal error LNK1120: 1 unresolved externals Debug\DSBGVD.exe
If I addoptional arguments in:
[fortran]CALL SYGV(A,B,EIGENVALUES_VEC,WORK,LWORK,INFO)[/fortran]

The error is:
Error 1 error #6285: There is no matching specific subroutine for this generic subroutine call. [SYGV]
Please note that the MLK subroutine changes values of the input matrices (A and B) after exit that why the performance index came up with that value.
If you disable all theMLK subroutines then you will have to rightperformance index from IMSL routines. For this comparision, I had added the MLK subroutines in middle of an IMSL example code that's the reason why that mix-up might happen.
0 Kudos
mecej4
Honored Contributor III
448 Views
> unresolved external symbol _DSYGV_MKL95

You must link the Lapack95 library.to resolve DSBGVD_MKL95 and DSYGV_MKL95. Do not try to compensate by changing the subroutine calls! See the MKL Link Line Advisor if necessary. For example, using IFort 12.0.5 x64, and IMSL6-x64,

s:\LANG > ifort /Qmkl /Qimsl goretrv.f90 mkl_lapack95_lp64.lib

With older versions of MKL, you were supplied sources and makefiles from which you could build the Lapack95 and Blas95 libraries. With current versions (12.0) these libraries come prebuilt.
0 Kudos
GoldenRetriever
Beginner
448 Views
Thanks mecej4, I missed out that part in the user's guide. Not sure how about other non-IT background guys doing with it, but it seems not easy to get all thing runs at once from the user's guides. I wish the user's guide should show everything needed to be done in one piece usingstep by step format..
Appreciated you helpmecej4.
0 Kudos
Reply