1 | MODULE lmdz_fft_mathkeisan |
---|
2 | #ifdef FFT_MATHKEISAN |
---|
3 | |
---|
4 | REAL,SAVE,ALLOCATABLE :: Table_forward(:) |
---|
5 | REAL,SAVE,ALLOCATABLE :: Table_backward(:) |
---|
6 | REAL,SAVE :: scale_factor |
---|
7 | INTEGER,SAVE :: vsize |
---|
8 | INTEGER,PARAMETER :: inc=2 |
---|
9 | |
---|
10 | CONTAINS |
---|
11 | |
---|
12 | SUBROUTINE Init_fft(iim,nb_vect_max) |
---|
13 | IMPLICIT NONE |
---|
14 | INTEGER :: iim |
---|
15 | INTEGER :: nb_vect_max |
---|
16 | REAL :: rtmp=1. |
---|
17 | COMPLEX :: ctmp |
---|
18 | INTEGER :: itmp=1 |
---|
19 | INTEGER :: isign=0 |
---|
20 | INTEGER :: ierr |
---|
21 | |
---|
22 | vsize=iim |
---|
23 | scale_factor=1./SQRT(1.*vsize) |
---|
24 | ALLOCATE(Table_forward(2*vsize+64)) |
---|
25 | ALLOCATE(Table_backward(2*vsize+64)) |
---|
26 | |
---|
27 | CALL DZFFTM(isign,vsize,itmp,scale_factor,rtmp,vsize+inc,ctmp,vsize/2+1,table_forward,rtmp,ierr) |
---|
28 | |
---|
29 | CALL ZDFFTM(isign,vsize,itmp,scale_factor,ctmp,vsize/2+1,rtmp,vsize+inc,table_backward,rtmp,ierr) |
---|
30 | |
---|
31 | |
---|
32 | END SUBROUTINE Init_fft |
---|
33 | |
---|
34 | |
---|
35 | SUBROUTINE fft_forward(vect,TF_vect,nb_vect) |
---|
36 | IMPLICIT NONE |
---|
37 | INTEGER,INTENT(IN) :: nb_vect |
---|
38 | REAL,INTENT(IN) :: vect(vsize+inc,nb_vect) |
---|
39 | COMPLEX,INTENT(OUT) :: TF_vect(vsize/2+1,nb_vect) |
---|
40 | REAL :: work(4*vsize*nb_vect) |
---|
41 | INTEGER :: ierr |
---|
42 | INTEGER, PARAMETER :: isign=-1 |
---|
43 | |
---|
44 | work=0 |
---|
45 | CALL DZFFTM(isign,vsize,nb_vect,scale_factor,vect,vsize+inc,TF_vect,vsize/2+1,table_forward,work,ierr) |
---|
46 | |
---|
47 | END SUBROUTINE fft_forward |
---|
48 | |
---|
49 | SUBROUTINE fft_backward(TF_vect,vect,nb_vect) |
---|
50 | IMPLICIT NONE |
---|
51 | INTEGER,INTENT(IN) :: nb_vect |
---|
52 | REAL,INTENT(OUT) :: vect(vsize+inc,nb_vect) |
---|
53 | COMPLEX,INTENT(IN ) :: TF_vect(vsize/2+1,nb_vect) |
---|
54 | REAL :: work(4*vsize*nb_vect) |
---|
55 | INTEGER :: ierr |
---|
56 | INTEGER, PARAMETER :: isign=1 |
---|
57 | |
---|
58 | work(:)=0 |
---|
59 | CALL ZDFFTM(isign,vsize,nb_vect,scale_factor,TF_vect,vsize/2+1,vect,vsize+inc,table_backward,work,ierr) |
---|
60 | |
---|
61 | END SUBROUTINE fft_backward |
---|
62 | |
---|
63 | #endif |
---|
64 | |
---|
65 | END MODULE lmdz_fft_mathkeisan |
---|
66 | |
---|
67 | |
---|