! C06PFF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE c06pffe_mod ! C06PFF 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 readx(nin,x,n1,n2) ! Read 2-dimensional complex data ! .. Implicit None Statement .. IMPLICIT NONE ! .. Scalar Arguments .. INTEGER, INTENT (IN) :: n1, n2, nin ! .. Array Arguments .. COMPLEX (KIND=nag_wp), INTENT (OUT) :: x(n1,n2) ! .. Local Scalars .. INTEGER :: i, j ! .. Executable Statements .. DO i = 1, n1 READ (nin,*) (x(i,j),j=1,n2) END DO RETURN END SUBROUTINE readx SUBROUTINE writx(nout,x,n1,n2) ! Print 2-dimensional complex data ! .. Implicit None Statement .. IMPLICIT NONE ! .. Scalar Arguments .. INTEGER, INTENT (IN) :: n1, n2, nout ! .. Array Arguments .. COMPLEX (KIND=nag_wp), INTENT (IN) :: x(n1,n2) ! .. Local Scalars .. INTEGER :: i, j ! .. Executable Statements .. DO i = 1, n1 WRITE (nout,*) WRITE (nout,99999) (x(i,j),j=1,n2) END DO RETURN 99999 FORMAT (1X,7(:1X,'(',F6.3,',',F6.3,')')) END SUBROUTINE writx END MODULE c06pffe_mod PROGRAM c06pffe ! C06PFF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : c06pff, nag_wp USE c06pffe_mod, ONLY : nin, nout, readx, writx ! .. Implicit None Statement .. IMPLICIT NONE ! .. Local Scalars .. INTEGER :: ieof, ifail, l, lwork, n, ndim ! .. Local Arrays .. COMPLEX (KIND=nag_wp), ALLOCATABLE :: work(:), x(:) INTEGER, ALLOCATABLE :: nd(:) ! .. Intrinsic Functions .. INTRINSIC product ! .. Executable Statements .. WRITE (nout,*) 'C06PFF 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 = n + nd(l) + 15 ALLOCATE (x(n),work(lwork)) CALL readx(nin,x,nd(1),nd(2)) WRITE (nout,*) WRITE (nout,*) 'Original data' CALL writx(nout,x,nd(1),nd(2)) ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 ! Compute transform CALL c06pff('F',ndim,l,nd,n,x,work,lwork,ifail) WRITE (nout,*) WRITE (nout,99999) 'Discrete Fourier transform of variable ', l CALL writx(nout,x,nd(1),nd(2)) ! Compute inverse transform CALL c06pff('B',ndim,l,nd,n,x,work,lwork,ifail) WRITE (nout,*) WRITE (nout,*) 'Original sequence as restored by inverse transform' CALL writx(nout,x,nd(1),nd(2)) DEALLOCATE (nd,x,work) END DO LOOP 99999 FORMAT (1X,A,I1) END PROGRAM c06pffe