! C06FXF Example Program Text
! Mark 25 Release. NAG Copyright 2014.
Module c06fxfe_mod
! C06FXF Example Program Module:
! Parameters and User-defined Routines
! .. Use Statements ..
Use nag_library, Only: nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Accessibility Statements ..
Private
Public :: readxy, writxy
! .. Parameters ..
Integer, Parameter, Public :: nin = 5, nout = 6
Contains
Subroutine readxy(nin,x,y,n1,n2,n3)
! Read 3-dimensional complex data
! .. Scalar Arguments ..
Integer, Intent (In) :: n1, n2, n3, nin
! .. Array Arguments ..
Real (Kind=nag_wp), Intent (Out) :: x(n1,n2,n3), y(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)
Read (nin,*)(y(i,j,k),k=1,n3)
End Do
End Do
Return
End Subroutine readxy
Subroutine writxy(nout,x,y,n1,n2,n3)
! Print 3-dimensional complex data
! .. Scalar Arguments ..
Integer, Intent (In) :: n1, n2, n3, nout
! .. Array Arguments ..
Real (Kind=nag_wp), Intent (In) :: x(n1,n2,n3), y(n1,n2,n3)
! .. Local Scalars ..
Integer :: i, j, k
! .. 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 ', (x(i,j,k),k=1,n3)
Write (nout,99999) 'Imag ', (y(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 writxy
End Module c06fxfe_mod
Program c06fxfe
! C06FXF Example Main Program
! .. Use Statements ..
Use nag_library, Only: c06fxf, c06gcf, nag_wp
Use c06fxfe_mod, Only: nin, nout, readxy, writxy
! .. Implicit None Statement ..
Implicit None
! .. Local Scalars ..
Integer :: ieof, ifail, n, n1, n2, n3
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: trign1(:), trign2(:), trign3(:), &
work(:), x(:), y(:)
! .. Executable Statements ..
Write (nout,*) 'C06FXF 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 (trign1(2*n1),trign2(2*n2),trign3(2*n3),work(2*n),x(n),y(n))
Call readxy(nin,x,y,n1,n2,n3)
Write (nout,*)
Write (nout,*) 'Original data values'
Call writxy(nout,x,y,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 c06fxf(n1,n2,n3,x,y,'Initial',trign1,trign2,trign3,work,ifail)
Write (nout,*)
Write (nout,*) 'Components of discrete Fourier transform'
Call writxy(nout,x,y,n1,n2,n3)
! -- Compute inverse transform
Call c06gcf(y,n,ifail)
Call c06fxf(n1,n2,n3,x,y,'Subsequent',trign1,trign2,trign3,work,ifail)
Call c06gcf(y,n,ifail)
Write (nout,*)
Write (nout,*) 'Original sequence as restored by inverse transform'
Call writxy(nout,x,y,n1,n2,n3)
Deallocate (trign1,trign2,trign3,work,x,y)
End Do loop
End Program c06fxfe