*     F01BVF Example Program Text
*     Mark 18 Revised. NAG Copyright 1997.
*     .. Parameters ..
      INTEGER          NMAX, MA1MAX, MB1MAX, M3, IA, IB, IV
      PARAMETER        (NMAX=20,MA1MAX=8,MB1MAX=8,M3=3*MA1MAX+MB1MAX-4,
     +                 IA=MA1MAX,IB=MB1MAX,IV=MA1MAX+MB1MAX-2)
      INTEGER          NIN, NOUT
      PARAMETER        (NIN=5,NOUT=6)
*     .. Local Scalars ..
      DOUBLE PRECISION ABSTOL
      INTEGER          I, IFAIL, INFO, J, K, M, M1, M2, MA1, MB1, N,
     +                 NSPLIT
*     .. Local Arrays ..
      DOUBLE PRECISION A(IA,NMAX), B(IB,NMAX), D(NMAX), E(NMAX),
     +                 R(NMAX), V(IV,M3), W(M3), WORK(4*NMAX)
      INTEGER          IBLOCK(NMAX), ISPLIT(NMAX), IWORK(3*NMAX)
*     .. External Subroutines ..
      EXTERNAL         DSBTRD, DSTEBZ, F01BUF, F01BVF
*     .. Intrinsic Functions ..
      INTRINSIC        MAX
*     .. Executable Statements ..
      WRITE (NOUT,*) 'F01BVF Example Program Results'
*     Skip heading in data file
      READ (NIN,*)
      READ (NIN,*) N, MA1, MB1
      IF (N.GT.0 .AND. N.LE.NMAX .AND. MA1.GE.0 .AND. MA1.LE.
     +    MA1MAX .AND. MB1.GE.0 .AND. MB1.LE.MB1MAX) THEN
         READ (NIN,*) ((A(J,I),J=MAX(1,MA1+1-I),MA1),I=1,N)
         READ (NIN,*) ((B(J,I),J=MAX(1,MB1+1-I),MB1),I=1,N)
         K = N/2
         IFAIL = 0
*
         CALL F01BUF(N,MB1,K,B,IB,W,IFAIL)
         CALL F01BVF(N,MA1,MB1,M3,K,A,IA,B,IB,V,IV,W,IFAIL)
         CALL DSBTRD('N','U',N,MA1-1,A,IA,D,E,W,1,WORK,INFO)
         IF (INFO.NE.0) THEN
            WRITE (NOUT,99999) 'DSBTRD', INFO
         ELSE
*
            ABSTOL = 0.0D0
            READ (NIN,*) M1, M2
*
            CALL DSTEBZ('I','E',N,0.0D0,0.0D0,M1,M2,ABSTOL,D,E,M,NSPLIT,
     +                  R,IBLOCK,ISPLIT,WORK,IWORK,INFO)
            IF (INFO.NE.0) THEN
               WRITE (NOUT,99999) 'DSTEBZ', INFO
            ELSE
               WRITE (NOUT,*)
               WRITE (NOUT,*) 'Selected eigenvalues'
               WRITE (NOUT,99998) (R(I),I=1,M)
            END IF
         END IF
      END IF
      STOP
*
99999 FORMAT (1X,'INFO from ',A6,' = ',I3)
99998 FORMAT (1X,8F9.4)
      END
