Prev: CIC filter
Next: Playing polygon games
From: Robert Orban on 10 Mar 2010 19:10 In article <95a66cf7-e379-407a-a299- 89057e6f3b48(a)d27g2000yqf.googlegroups.com>, jinbow(a)gmail.com says... > > >Hello, >I tried to test the sin transform using fftw, met some problems which >I had no clue what's the reason. > >The following is my program, it first does sin transform of sin([1:7]/ >8*pi) use flags :FFTW_RODFT00,FFTW_ESTIMATE and there's no problem. >Problem appeared after I try to reuse the 'plan' to do inverse, which >gave 'Segmentation fault'. If I recreate the plan again, the problem >disappears. Also the Segmentation fault appeared whenever I call >dfftw_destroy_plan(plan). > >I'll appreciate your wisdom. >JBW >----------------------------------------------------- >program testdst > implicit none > include 'fftw3.f' > integer, parameter :: N=7 > integer :: i, plan > real*8, dimension(N)::in,out > real*8, parameter :: PI=3.14159265358979 > do i = 1,7 > in(i) = sin(real(i)/8*PI) > enddo > write(*,'(7f6.2)') in > call dfftw_plan_r2r_1d(plan,N,in,out,FFTW_RODFT00,FFTW_MEASURE) > call dfftw_execute(plan,N,in,out) > write(*,'(7f6.2)') out >! call dfftw_execute(plan,N,in,out) >! write(*,'(7f6.2)') in >end program testdst > >output: > 0.38 0.71 0.92 1.00 0.92 0.71 0.38 > 8.00 0.00 -0.00 0.00 -0.00 0.00 -0.00 > >if this two lines are uncommented >! call dfftw_execute(plan,N,in,out) >! write(*,'(7f6.2)') in >then I got output: > 0.38 0.71 0.92 1.00 0.92 0.71 0.38 > 8.00 0.00 -0.00 0.00 -0.00 0.00 -0.00 >Segmentation fault You might want to post your question to comp.lang.fortran. Sometimes, problems like this are caused by mismatches between a called subroutine and the caller. Putting the two called subroutines in a module and Using the module in the main program will force the compiler to generate an explicit interface for each subroutine automatically. This might help diagnose your problem. Your compiler probably has an option to turn on run-time checking of array bounds, detecting if the program when running tries to write to unallocated memory. This is another thing to try.
|
Pages: 1 Prev: CIC filter Next: Playing polygon games |