|
| 1 | +program main |
| 2 | +use fftpack, only: zffti, zfftf, zfftb, fft, ifft |
| 3 | +use fftpack_kind, only: rk |
| 4 | + |
| 5 | +implicit none |
| 6 | +integer, parameter :: N = 1024*135*77 !> (2**10)*(3**3)*5*7*11 |
| 7 | + |
| 8 | +complex(rk), dimension(N) :: x, z |
| 9 | +real(rk), dimension(4*N+15) :: w |
| 10 | +real(rk) :: err, time_i, time_f, time_b, t1, t2 |
| 11 | + |
| 12 | +call random_number(x%re) |
| 13 | +z = x |
| 14 | + |
| 15 | +print *, "02: Benchmarking zfft & fft" |
| 16 | + |
| 17 | +call cpu_time(t1) |
| 18 | +call zffti(N, w) |
| 19 | +call cpu_time(t2) |
| 20 | +time_i = t2-t1 |
| 21 | +print *, "Initializing: done" |
| 22 | + |
| 23 | +call cpu_time(t1) |
| 24 | +call zfftf(N, z, w) |
| 25 | +call cpu_time(t2) |
| 26 | +time_f = t2-t1 |
| 27 | +print *, "Forward: done" |
| 28 | + |
| 29 | +call cpu_time(t1) |
| 30 | +call zfftb(N, z, w) |
| 31 | +call cpu_time(t2) |
| 32 | +time_b = t2-t1 |
| 33 | +print *, "Backward: done" |
| 34 | +print *, "" |
| 35 | + |
| 36 | +err = maxval(abs(x-real(z/N,rk))) |
| 37 | +print *, "--zfft" |
| 38 | +print *, "Error: ", err |
| 39 | +print *, "Init. time: ", time_i |
| 40 | +print *, "Forward time: ", time_f |
| 41 | +print *, "Backward time: ", time_b |
| 42 | +print *, "" |
| 43 | + |
| 44 | +print *, "Comparing to calls through fft" |
| 45 | +call cpu_time(t1) |
| 46 | +z = fft(x) |
| 47 | +call cpu_time(t2) |
| 48 | +time_f = t2-t1 |
| 49 | +print *, "Init. & forward: done" |
| 50 | + |
| 51 | +call cpu_time(t1) |
| 52 | +z = ifft(z) |
| 53 | +call cpu_time(t2) |
| 54 | +time_b = t2-t1 |
| 55 | +print *, "Backward: done" |
| 56 | +print *, "" |
| 57 | + |
| 58 | +err = maxval(abs(x-real(z/N,rk))) |
| 59 | +print *, "--fft" |
| 60 | +print *, "Error: ", err |
| 61 | +print *, "Init. & forward time: ", time_f |
| 62 | +print *, "Backward time: ", time_b |
| 63 | +print *, "" |
| 64 | +end program |
0 commit comments