Program c06gsfe

!     C06GSF Example Program Text

!     Mark 25 Release. NAG Copyright 2014.

!     .. Use Statements ..
      Use nag_library, Only: 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,*) 'C06GSF 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
        Deallocate (u,v,x)
      End Do loop

99999 Format (1X,A,6F10.4)
    End Program c06gsfe