! C06PXF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE c06pxfe_mod ! C06PXF 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,n3) ! Read 3-dimensional complex data ! .. Implicit None Statement .. IMPLICIT NONE ! .. Scalar Arguments .. INTEGER, INTENT (IN) :: n1, n2, n3, nin ! .. Array Arguments .. COMPLEX (KIND=nag_wp), INTENT (OUT) :: x(n1,n2,n3) ! .. Local Scalars .. INTEGER :: i, j, k ! .. Executable Statements .. DO i = 1, n1 DO j = 1, n2 READ (nin,*) (x(i,j,k),k=1,n3) END DO END DO RETURN END SUBROUTINE readx SUBROUTINE writx(nout,x,n1,n2,n3) ! Print 3-dimensional complex data ! .. Implicit None Statement .. IMPLICIT NONE ! .. Scalar Arguments .. INTEGER, INTENT (IN) :: n1, n2, n3, nout ! .. Array Arguments .. COMPLEX (KIND=nag_wp), INTENT (IN) :: x(n1,n2,n3) ! .. Local Scalars .. INTEGER :: i, j, k ! .. Intrinsic Functions .. INTRINSIC aimag, real ! .. Executable Statements .. DO i = 1, n1 WRITE (nout,*) WRITE (nout,99998) 'z(i,j,k) for i =', i DO j = 1, n2 WRITE (nout,*) WRITE (nout,99999) 'Real ', (real(x(i,j,k)),k=1,n3) WRITE (nout,99999) 'Imag ', (aimag(x(i,j,k)),k=1,n3) END DO END DO RETURN 99999 FORMAT (1X,A,7F10.3/(6X,7F10.3)) 99998 FORMAT (1X,A,I6) END SUBROUTINE writx END MODULE c06pxfe_mod PROGRAM c06pxfe ! C06PXF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : c06pxf, nag_wp USE c06pxfe_mod, ONLY : nin, nout, readx, writx ! .. Implicit None Statement .. IMPLICIT NONE ! .. Local Scalars .. INTEGER :: ieof, ifail, n, n1, n2, n3 ! .. Local Arrays .. COMPLEX (KIND=nag_wp), ALLOCATABLE :: work(:), x(:) ! .. Executable Statements .. WRITE (nout,*) 'C06PXF Example Program Results' ! Skip heading in data file READ (nin,*) LOOP: DO READ (nin,*,IOSTAT=ieof) n1, n2, n3 IF (ieof<0) EXIT LOOP n = n1*n2*n3 ALLOCATE (x(n),work(n+n1+n2+n3+45)) CALL readx(nin,x,n1,n2,n3) WRITE (nout,*) WRITE (nout,*) 'Original data values' CALL writx(nout,x,n1,n2,n3) ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 ! -- Compute transform CALL c06pxf('F',n1,n2,n3,x,work,ifail) WRITE (nout,*) WRITE (nout,*) 'Components of discrete Fourier transform' CALL writx(nout,x,n1,n2,n3) ! -- Compute inverse transform CALL c06pxf('B',n1,n2,n3,x,work,ifail) WRITE (nout,*) WRITE (nout,*) 'Original sequence as restored by inverse transform' CALL writx(nout,x,n1,n2,n3) DEALLOCATE (x,work) END DO LOOP END PROGRAM c06pxfe