In the Fortran array A(I,J) is stored with I varying fastest
Dimension A2d(27,31),A1d(27*31)
Equivalence (A1d(1),A2d(27,31))
A1d(I+(31)*(J-1))=A2d(I,J)
If the Array A(I,J) was written to the disk with the commands
OPEN(1,
Do j=1,31
Write(1)(A(I,j),i=1,27)
Enddo
CLOSE(1)
The one dimensional array can be read and used with the code
OPEN(2,
Dimension A1d(27)
Do
j=1,31
READ(1)(Aid(I),i=1,27)
Call proc(A1d,27)
Write(2)(A1d(I),i=1,27)
Enddo
CLOSE(2)
The segment of code above uses much less memory than the first two segments. In ..\..\Fourier\DFT2-FFT2.docx, only the simple transform uses the entire array. The intermediate transform requires a single re-order, while the fft requires “essentially” two re-orders. If the procedure is a fast Fourier transform in the x direction. The result is
dd(x,y)àDd(fx,y)
If Dd will fit in memory, the easiest way to make the y transform is coded into reorder.for
open(1,file=iin,form='unformatted')
do j=1,ny
read(1)(dd(i,j),i=1,nx)
enddo
close(1)
open(2,file=iiout,form='unformatted')
do i=1,nx
write(2)(dd(i,j),j=1,ny)
enddo
This is both simple and fast Dd(fx,y) àDD(fy,fx). On a computer with 4g of memory, the nalues of nx and ny could be 10,000 each and the allocation preceeding the step above still worked. – On older computer with less memory about 1000 is the limit. The FFT, however, has the speed necessary to handle enormous arrays in nx and ny. If the allocation fails, it makes sense to use a direct access file to achieve the same result.
Two re-orders are needed for hh(x,y)à HH(fx,fy)
The simple
reorder requires 0.22 seconds, while the DA reorder requires 0.34 seconds. This is worse but …
C:\Public\TwoDFT>twodft
n2px is power of 2 > max(nx,nfx)
enter XINT, nx, nfx, n2px
20,200,100,256
enter YINT, ny, nfy, n2py
10,100,100,128
FFT transform
sec
0.2200000
C:\Public\TwoDFT>twodft
n2px is power of 2 > max(nx,nfx)
enter XINT, nx, nfx, n2px
20,200,100,256
enter YINT, ny, nfy, n2py
10,100,100,128
allocation failed using DA reordering
allocation failed using DA reordering
FFT transform
sec
0.3400000