[Fortran] 纯文本查看 复制代码
PROGRAM MAIN
USE mkl95_PRECISION
USE mkl95_LAPACK, ONLY: GGEV
IMPLICIT NONE
CHARACTER*1 JOBVL,JOBVR
INTEGER*8 I,J,N,LDA,LDB,K,INFO,LDVL,LDVR
INTEGER*8 :: LWORK
REAL*8,ALLOCATABLE:: WORK(:)
REAL*8,ALLOCATABLE:: RA(:,:),RB(:,:)
REAL*8,ALLOCATABLE:: BETA(:),ALPHAR(:),ALPHAI(:)
COMPLEX*16,ALLOCATABLE::VL(:,:),VR(:,:)
N=5
LDA=N
LDB=N
LDVR=N
LDVL=N
LWORK=MAX(1,8*N+16)
INFO=0
ALLOCATE(RA(LDA,N),RB(LDB,N),WORK(MAX(1,LWORK)),BETA(N),
+ALPHAR(N),ALPHAI(N),VL(LDVL,N),VR(LDVR,N))
RA=0.0D0
RB=0.0D0
VR=0.0D0
VL=0.0D0
ALPHAR=0.0D0
ALPHAI=0.0D0
OPEN(5,FILE='A.INP',STATUS='OLD', ACTION='READ')! INPUT FILE
OPEN(6,FILE='A.DAT', STATUS='NEW', ACTION='WRITE') ! OUTPUT FILE
WRITE (6,*) 'GEEVX Example Program Results'
DO I=1,N
READ(5,*)(RA(I,J),J=1,N)
ENDDO
DO I=1,N
READ(5,*)(RB(I,J),J=1,N)
ENDDO
WRITE(6,*)'Matrix RA:'
DO I=1,N
WRITE(6,"(5(E13.6,1X))")RA(I,:)
ENDDO
WRITE(6,*)'Matrix RB:'
DO I=1,N
WRITE(6,"(5(E13.6,1X))")RB(I,:)
ENDDO
JOBVL='N'
JOBVR='V'
CALL DGGEV(JOBVL,JOBVR,N,RA,LDA,RB,LDB,ALPHAR,ALPHAI,BETA,VL,
+LDVL,VR,LDVR,WORK,LWORK,INFO)
WRITE(6,*)' Generalized eigenvalues : '
DO I=1,N
WRITE(6,*) '(',ALPHAR(I)/BETA(I),',',ALPHAI(I)/BETA(I),')'
ENDDO
WRITE(6,*)' Eigenvectors : '
DO I=1,N
WRITE(6,"(5(F8.5,1X,',',F8.5))") REAL(VR(I,:)),AIMAG(VR(I,:))
ENDDO
END PROGRAM MAIN