! C06FFF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE c06fffe_mod ! C06FFF Example Program Module: ! Parameters and User-defined Routines ! .. Use Statements .. USE nag_library, ONLY : nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 CONTAINS SUBROUTINE readxy(nin,x,y,n1,n2) ! Read 2-dimensional complex data ! .. Implicit None Statement .. IMPLICIT NONE ! .. Scalar Arguments .. INTEGER, INTENT (IN) :: n1, n2, nin ! .. Array Arguments .. REAL (KIND=nag_wp), INTENT (OUT) :: x(n1,n2), y(n1,n2) ! .. Local Scalars .. INTEGER :: i, j ! .. Executable Statements .. DO i = 1, n1 READ (nin,*) (x(i,j),j=1,n2) READ (nin,*) (y(i,j),j=1,n2) END DO RETURN END SUBROUTINE readxy SUBROUTINE writxy(nout,x,y,n1,n2) ! Print 2-dimensional complex data ! .. Implicit None Statement .. IMPLICIT NONE ! .. Scalar Arguments .. INTEGER, INTENT (IN) :: n1, n2, nout ! .. Array Arguments .. REAL (KIND=nag_wp), INTENT (IN) :: x(n1,n2), y(n1,n2) ! .. Local Scalars .. INTEGER :: i, j ! .. Executable Statements .. DO i = 1, n1 WRITE (nout,*) WRITE (nout,99999) 'Real ', (x(i,j),j=1,n2) WRITE (nout,99999) 'Imag ', (y(i,j),j=1,n2) END DO RETURN 99999 FORMAT (1X,A,7F10.3/(6X,7F10.3)) END SUBROUTINE writxy END MODULE c06fffe_mod PROGRAM c06fffe ! C06FFF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : c06fff, c06gcf, nag_wp USE c06fffe_mod, ONLY : nin, nout, readxy, writxy ! .. Implicit None Statement .. IMPLICIT NONE ! .. Local Scalars .. INTEGER :: ieof, ifail, l, lwork, n, ndim ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: work(:), x(:), y(:) INTEGER, ALLOCATABLE :: nd(:) ! .. Intrinsic Functions .. INTRINSIC product ! .. Executable Statements .. WRITE (nout,*) 'C06FFF Example Program Results' ! Skip heading in data file READ (nin,*) LOOP: DO READ (nin,*,IOSTAT=ieof) ndim IF (ieof<0) EXIT LOOP ALLOCATE (nd(ndim)) READ (nin,*) nd(1:ndim), l n = product(nd(1:ndim)) lwork = 3*nd(l) ALLOCATE (x(n),y(n),work(lwork)) CALL readxy(nin,x,y,nd(1),nd(2)) WRITE (nout,*) WRITE (nout,*) 'Original data' CALL writxy(nout,x,y,nd(1),nd(2)) ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ! Compute transform ifail = 0 CALL c06fff(ndim,l,nd,n,x,y,work,lwork,ifail) WRITE (nout,*) WRITE (nout,99999) 'Discrete Fourier transform of variable ', l CALL writxy(nout,x,y,nd(1),nd(2)) ! Compute inverse transform CALL c06gcf(y,n,ifail) CALL c06fff(ndim,l,nd,n,x,y,work,lwork,ifail) CALL c06gcf(y,n,ifail) WRITE (nout,*) WRITE (nout,*) 'Original sequence as restored by inverse transform' CALL writxy(nout,x,y,nd(1),nd(2)) DEALLOCATE (x,y,work,nd) END DO LOOP 99999 FORMAT (1X,A,I1) END PROGRAM c06fffe