    PROGRAM f02gcfe

!      F02GCF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : f02gcf, nag_wp, x04dbf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: wl, wu
       INTEGER                         :: i, ifail, lda, ldv, lwork, m, mest, n
!      .. Local Arrays ..
       COMPLEX (KIND=nag_wp), ALLOCATABLE :: a(:,:), v(:,:), w(:), work(:)
       REAL (KIND=nag_wp), ALLOCATABLE :: rwork(:)
       INTEGER, ALLOCATABLE            :: iwork(:)
       LOGICAL, ALLOCATABLE            :: bwork(:)
       CHARACTER (1)                   :: clabs(1), rlabs(1)
!      .. Executable Statements ..
       WRITE (nout,*) 'F02GCF Example Program Results'
!      Skip heading in data file
       READ (nin,*)
       READ (nin,*) n, mest, wl, wu
       lda = n
       ldv = n
       lwork = 64*n
       ALLOCATE (a(lda,n),v(ldv,n),w(n),work(lwork),rwork(2*n),iwork(n), &
          bwork(n))
!      Read A from data file
       READ (nin,*) (a(i,1:n),i=1,n)

!      Compute selected eigenvalues and eigenvectors of A

!      ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
       ifail = 0
       CALL f02gcf('Moduli',n,a,lda,wl,wu,mest,m,w,v,ldv,work,lwork,rwork, &
          iwork,bwork,ifail)

       WRITE (nout,*)
       WRITE (nout,*) 'Eigenvalues'
       WRITE (nout,99999) w(1:m)
       WRITE (nout,*)
       FLUSH (nout)

       ifail = 0
       CALL x04dbf('General',' ',n,m,v,ldv,'Bracketed','F7.4','Eigenvectors', &
          'Integer',rlabs,'Integer',clabs,80,0,ifail)

99999  FORMAT ((3X,4(' (',F7.4,',',F7.4,')':)))
    END PROGRAM f02gcfe
