*     C06PAF Example Program Text
*     Mark 19 Release. NAG Copyright 1999.
*     .. Parameters ..
      INTEGER          NIN, NOUT
      PARAMETER        (NIN=5,NOUT=6)
      INTEGER          NMAX
      PARAMETER        (NMAX=20)
*     .. Local Scalars ..
      INTEGER          IFAIL, J, N, NJ
*     .. Local Arrays ..
      DOUBLE PRECISION WORK(3*NMAX+15), X(0:NMAX+1), XX(0:NMAX-1)
*     .. External Subroutines ..
      EXTERNAL         C06PAF
*     .. Executable Statements ..
      WRITE (NOUT,*) 'C06PAF Example Program Results'
*     Skip heading in data file
      READ (NIN,*)
   20 CONTINUE
      READ (NIN,*,END=120) N
      IF (N.GT.1 .AND. N.LE.NMAX) THEN
         DO 40 J = 0, N - 1
            READ (NIN,*) X(J)
            XX(J) = X(J)
   40    CONTINUE
         IFAIL = 0
*
         CALL C06PAF('F',X,N,WORK,IFAIL)
*
         WRITE (NOUT,*)
         WRITE (NOUT,*) 'Components of discrete Fourier transform'
         WRITE (NOUT,*)
         WRITE (NOUT,*) '          Real      Imag'
         WRITE (NOUT,*)
         DO 60 J = 0, N/2
            WRITE (NOUT,99999) J, X(2*J), X(2*J+1)
   60    CONTINUE
         DO 80 J = N/2 + 1, N - 1
            NJ = N - J
            WRITE (NOUT,99999) J, X(2*NJ), -X(2*NJ+1)
   80    CONTINUE
*
         CALL C06PAF('B',X,N,WORK,IFAIL)
*
         WRITE (NOUT,*)
         WRITE (NOUT,*)
     +     'Original sequence as restored by inverse transform'
         WRITE (NOUT,*)
         WRITE (NOUT,*) '        Original  Restored'
         WRITE (NOUT,*)
         DO 100 J = 0, N - 1
            WRITE (NOUT,99999) J, XX(J), X(J)
  100    CONTINUE
         GO TO 20
      ELSE
         WRITE (NOUT,*) 'Invalid value of N'
      END IF
  120 CONTINUE
      STOP
*
99999 FORMAT (1X,I5,2F10.5)
      END
