FFT 2D subroutines


Feynman
02-26-2008, 10:41 AM
Hello
I m searching a complete program wich calculate the FFT of a matrix,
could you help me?
thankx

fateme.mirjani
07-07-2008, 02:05 AM
Dear all;
I'm going to use rlft3.f90 (3D Fast Fourier transform subroutine in Numerical Recipes in Fortran book)
I have constructed a 100*100*100 mesh as data. (a special Step-Function)
I should call rlft3(data,speg,nn1,nn2,nn3,isign).
-----------------------------------------------------------------------------
SUBROUTINE rlft3(data,speq,nn1,nn2,nn3,isign)
INTEGER isign,nn1,nn2,nn3
COMPLEX data(nn1/2,nn2,nn3),speq(nn2,nn3)
-----------------------------------------------------------------------------
1- I don't understand why for data is written nn1/2 ? I have a 100*100*100 mesh!!! Does it mean that for a 100*100*100 mesh I should consider 50*100*100 ??

2- I don't know what should I put instead of speq? Is speg input or output?
When I run the program I envisaged the Segmentation fault error.


I'm anxiously looking forward your reply and guidlines.
With my best regards,
Fatemeh
[/FONT]

davekw7x
07-09-2008, 12:59 AM
.
1- I don't understand why for data is written nn1/2 ? I have a 100*100*100 mesh!!!

First of all, the function is written in such a way that the sizes must be powers of 2 (So you would use a 128x128x128 array, not 100x100x100.) This is stated in the text. The F90 version of rlft3 detects invalid values, but the F77 code does not.

Secondly, the complex array whose sizes are 64,128,128 occupies the same amount of memory as a floating point array with sizes 128,128,128, and that's the way it is used inside the function. (Good old Fortran lets you do that!)


2- I don't know what should I put instead of speq? Is speg input or output?This is covered in the narrative (including some figures) in the text and in comments in the code in the text. The input is your data array. The function overwrites your input matrix and puts some of its output in speq. (You declare speq to be a 2D complex array with sizes 128x128.)

The code is presented as a way to exercise the knowledge you obtain from the text. My feeling is that understanding how the stuff gets accessed in memory is just about as tricky (maybe even more difficult to understand) than the algorithm itself. It takes a little "getting used to." The tricky stuff (some might even call it sneaky) is put there in an effort to make memory size and access speed better than some more obvious (naive) methods that I have seen.

When I run the program I envisaged the Segmentation fault error.

How can we guess??? How did you declare and initialize the data matrix? How did you call the function? Maybe you can show us some code?

What compiler and what operating system are you using? I mean, with GNU Fortran compilers on my Linux systems, I have no problems with a 128x128x128 data matrix and a 128x128 complex matrix for speq, but I don't know whether there are memory limitations on other implementations. Did you try with smaller matrices?

Regards,

Dave