PROGRAM c06hbfe ! C06HBF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : c06hbf, 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 :: trig(:), work(:), x(:) ! .. Executable Statements .. WRITE (nout,*) 'C06HBF Example Program Results' ! Skip heading in data file READ (nin,*) LOOP: DO READ (nin,*,IOSTAT=ieof) m, n IF (ieof<0) EXIT LOOP ALLOCATE (trig(2*n),work(m*n),x(m*(n+1))) DO j = 1, m READ (nin,*) (x(i*m+j),i=0,n) 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) END DO ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 ! -- Compute transform CALL c06hbf(m,n,x,'Initial',trig,work,ifail) WRITE (nout,*) WRITE (nout,*) 'Discrete Fourier cosine transforms' WRITE (nout,*) DO j = 1, m WRITE (nout,99999) (x(i*m+j),i=0,n) END DO ! -- Compute inverse transform CALL c06hbf(m,n,x,'Subsequent',trig,work,ifail) WRITE (nout,*) WRITE (nout,*) 'Original data as restored by inverse transform' WRITE (nout,*) DO j = 1, m WRITE (nout,99999) (x(i*m+j),i=0,n) END DO DEALLOCATE (trig,work,x) END DO LOOP 99999 FORMAT (6X,7F10.4) END PROGRAM c06hbfe