NAG Library Manual, Mark 30.3
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program c06rhfe

!     C06RHF Example Program Text

!     Mark 30.3 Release. nAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: c06rhf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: idir, ieof, ifail, j, m, n
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: x(:,:)
!     .. Executable Statements ..
      Write (nout,*) 'C06RHF Example Program Results'
!     Skip heading in data file
      Read (nin,*)
loop: Do
        Read (nin,*,Iostat=ieof) m, n
        If (ieof<0) Then
          Exit loop
        End If

        Allocate (x(0:n-1,m))
        Read (nin,*)(x(0:n-1,j),j=1,m)
        Write (nout,*)
        Write (nout,*) 'Original data values'
        Write (nout,*)
        Write (nout,99999)(x(0:n-1,j),j=1,m)

!       ifail: behaviour on error exit
!              =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
        ifail = 0
!       -- Compute transform
        idir = 1
        Call c06rhf(idir,m,n,x,ifail)

        Write (nout,*)
        Write (nout,*) 'Discrete quarter-wave Fourier cosine transforms'
        Write (nout,*)
        Write (nout,99999)(x(0:n-1,j),j=1,m)

!       -- Compute inverse transform
        idir = -1
        Call c06rhf(idir,m,n,x,ifail)

        Write (nout,*)
        Write (nout,*) 'Original data as restored by inverse transform'
        Write (nout,*)
        Write (nout,99999)(x(0:n-1,j),j=1,m)
        Deallocate (x)
      End Do loop

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