    PROGRAM c06gqfe

!      C06GQF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : c06gqf, c06gsf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: i, ieof, ifail, j, m, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: u(:), v(:), x(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'C06GQF Example Program Results'
!      Skip heading in data file
       READ (nin,*)
LOOP:  DO
          READ (nin,*,IOSTAT=ieof) m, n
          IF (ieof<0) EXIT LOOP

          ALLOCATE (u(m*n),v(m*n),x(m*n))
          DO j = 1, m
             READ (nin,*) (x(i*m+j),i=0,n-1)
          END DO
          WRITE (nout,*)
          WRITE (nout,*) 'Original data values'
          WRITE (nout,*)
          DO j = 1, m
             WRITE (nout,99999) '     ', (x(i*m+j),i=0,n-1)
          END DO
          WRITE (nout,*)
          WRITE (nout,*) 'Original data written in full complex form'

!         ifail: behaviour on error exit   
!                =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
          ifail = 0
          CALL c06gsf(m,n,x,u,v,ifail)

          DO j = 1, m
             WRITE (nout,*)
             WRITE (nout,99999) 'Real ', (u(i*m+j),i=0,n-1)
             WRITE (nout,99999) 'Imag ', (v(i*m+j),i=0,n-1)
          END DO

          CALL c06gqf(m,n,x,ifail)

          WRITE (nout,*)
          WRITE (nout,*) 'Conjugated data values'
          WRITE (nout,*)
          DO j = 1, m
             WRITE (nout,99999) '     ', (x(i*m+j),i=0,n-1)
          END DO

          CALL c06gsf(m,n,x,u,v,ifail)

          WRITE (nout,*)
          WRITE (nout,*) 'Conjugated data written in full complex form'

          CALL c06gsf(m,n,x,u,v,ifail)

          DO j = 1, m
             WRITE (nout,*)
             WRITE (nout,99999) 'Real ', (u(i*m+j),i=0,n-1)
             WRITE (nout,99999) 'Imag ', (v(i*m+j),i=0,n-1)
          END DO
          DEALLOCATE (u,v,x)
       END DO LOOP

99999  FORMAT (1X,A,6F10.4)
    END PROGRAM c06gqfe
