Program f08jbfe ! F08JBF Example Program Text ! Mark 24 Release. NAG Copyright 2012. ! .. Use Statements .. Use nag_library, Only: dstevx, nag_wp, x02amf, x04caf ! .. Implicit None Statement .. Implicit None ! .. Parameters .. Integer, Parameter :: nin = 5, nout = 6 ! .. Local Scalars .. Real (Kind=nag_wp) :: abstol, vl, vu Integer :: ifail, il, info, iu, ldz, m, n ! .. Local Arrays .. Real (Kind=nag_wp), Allocatable :: d(:), e(:), w(:), work(:), z(:,:) Integer, Allocatable :: iwork(:), jfail(:) ! .. Executable Statements .. Write (nout,*) 'F08JBF Example Program Results' Write (nout,*) ! Skip heading in data file Read (nin,*) Read (nin,*) n ldz = n m = n Allocate (d(n),e(n),w(n),work(5*n),z(ldz,m),iwork(5*n),jfail(n)) ! Read the lower and upper bounds of the interval to be searched, ! and read the diagonal and off-diagonal elements of the matrix ! A from data file Read (nin,*) vl, vu Read (nin,*) d(1:n) Read (nin,*) e(1:n-1) ! Set the absolute error tolerance for eigenvalues. With ABSTOL ! set to zero, the default value would be used instead abstol = 2.0E0_nag_wp*x02amf() ! Solve the symmetric eigenvalue problem ! The NAG name equivalent of dstevx is f08jbf Call dstevx('Vectors','Values in range',n,d,e,vl,vu,il,iu,abstol,m,w,z, & ldz,work,iwork,jfail,info) If (info>=0) Then ! Print solution Write (nout,99999) 'Number of eigenvalues found =', m Write (nout,*) Write (nout,*) 'Eigenvalues' Write (nout,99998) w(1:m) Flush (nout) ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 Call x04caf('General',' ',n,m,z,ldz,'Selected eigenvectors',ifail) If (info>0) Then Write (nout,99999) 'INFO eigenvectors failed to converge, INFO =', & info Write (nout,*) 'Indices of eigenvectors that did not converge' Write (nout,99997) jfail(1:m) End If Else Write (nout,99999) 'Failure in DSTEVX. INFO =', info End If 99999 Format (1X,A,I5) 99998 Format (3X,(8F8.4)) 99997 Format (3X,(8I8)) End Program f08jbfe