PROGRAM f08pnfe ! F08PNF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : f08pnz, nag_wp, x04dbf, zgees, zgemm ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nb = 64, nin = 5, nout = 6 ! .. Local Scalars .. COMPLEX (KIND=nag_wp) :: alpha, beta INTEGER :: i, ifail, info, lda, ldc, ldd, ldvs, & lwork, n, sdim ! .. Local Arrays .. COMPLEX (KIND=nag_wp), ALLOCATABLE :: a(:,:), c(:,:), d(:,:), vs(:,:), & w(:), work(:) COMPLEX (KIND=nag_wp) :: wdum(1) REAL (KIND=nag_wp), ALLOCATABLE :: rwork(:) LOGICAL :: dummy(1) CHARACTER (1) :: clabs(1), rlabs(1) ! .. Intrinsic Functions .. INTRINSIC cmplx, max, nint, real ! .. Executable Statements .. WRITE (nout,*) 'F08PNF Example Program Results' WRITE (nout,*) FLUSH (nout) ! Skip heading in data file READ (nin,*) READ (nin,*) n lda = n ldc = n ldd = n ldvs = n ALLOCATE (a(lda,n),vs(ldvs,n),c(ldc,n),d(ldd,n),w(n),rwork(n)) ! Use routine workspace query to get optimal workspace. lwork = -1 ! The NAG name equivalent of zgees is f08pnf CALL zgees('Vectors (Schur)','No sort',f08pnz,n,a,lda,sdim,w,vs,ldvs, & wdum,lwork,rwork,dummy,info) ! Make sure that there is enough workspace for blocksize nb. lwork = max((nb+1)*n,nint(real(wdum(1)))) ALLOCATE (work(lwork)) ! Read the matrix A from data file READ (nin,*) (a(i,1:n),i=1,n) ! print matrix A ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 CALL x04dbf('General',' ',n,n,a,lda,'Bracketed','F7.4','Matrix A', & 'Integer',rlabs,'Integer',clabs,80,0,ifail) WRITE (nout,*) FLUSH (nout) ! Find the Schur factorization ! The NAG name equivalent of zgees is f08pnf CALL zgees('Vectors (Schur)','No sort',f08pnz,n,a,lda,sdim,w,vs,ldvs, & work,lwork,rwork,dummy,info) IF (info>0) THEN WRITE (nout,99999) 'Failure in ZGEES. INFO =', info ELSE ! Compute Z * T * Z**H from Schur factorization of A alpha = cmplx(1,kind=nag_wp) beta = cmplx(0,kind=nag_wp) CALL zgemm('N','N',n,n,n,alpha,vs,ldvs,a,lda,beta,c,ldc) CALL zgemm('N','C',n,n,n,alpha,c,ldc,vs,ldvs,beta,d,ldd) WRITE (nout,*) FLUSH (nout) ! Print matrix A ifail = 0 CALL x04dbf('General',' ',n,n,d,ldd,'Bracketed','F7.4', & 'Matrix A re-created from Schur factorization Z*T*Z^H','Integer', & rlabs,'Integer',clabs,80,0,ifail) END IF 99999 FORMAT (1X,A,I4) END PROGRAM f08pnfe