    PROGRAM nag_sym_fft_ex05

      ! Example Program Text for nag_sym_fft
      ! NAG fl90, Release 4. NAG Copyright 2000.

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_in, nag_std_out
      USE nag_sym_fft, ONLY : nag_fft_sin
      USE nag_write_mat, ONLY : nag_write_gen_mat
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i, m, n
      ! .. Local Arrays ..
      REAL (wp), ALLOCATABLE :: x(:,:), xhat(:,:)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_sym_fft_ex05'

      READ (nag_std_in,*)          ! Skip heading in data file
      READ (nag_std_in,*) m, n

      ALLOCATE (x(m,n-1),xhat(m,n-1)) ! Allocate storage

      DO i = 1, m
        READ (nag_std_in,*) x(i,:)
      END DO
      WRITE (nag_std_out,*)

      CALL nag_write_gen_mat(x,format='f10.4',int_row_labels=.TRUE., &
       title='Original data')

      WRITE (nag_std_out,*)

      xhat = nag_fft_sin(x)

      CALL nag_write_gen_mat(xhat,format='f10.4',int_row_labels=.TRUE., &
       title='Transformed data')

      WRITE (nag_std_out,*)

      x = nag_fft_sin(xhat)

      CALL nag_write_gen_mat(x,format='f10.4',int_row_labels=.TRUE., &
       title='Original data restored by inverse transform')

      DEALLOCATE (x,xhat)          ! Deallocate storage

    END PROGRAM nag_sym_fft_ex05
