Line data Source code
1 : MODULE m_fft3d 2 : CONTAINS 3 2986 : SUBROUTINE fft3d(& 4 2986 : & afft, bfft, fg3,& 5 : & stars, isn, scaled) 6 : 7 : !************************************************************ 8 : !* * 9 : !* interface for fg3(star) -- FFT --> (a,b)fft (r) (isn=+1) * 10 : !* or (a,b)fft (r) -- FFT --> fg3(star) (isn=-1) * 11 : !* * 12 : !* dimension of (a,b)fft is (3*k1d x 3*k2d x 3*k3d) * 13 : !* afft and bfft contain the real/imaginary part of the FFT * 14 : !* igfft(i,1) is the pointer from the G-sphere to stars * 15 : !* igfft(i,2) is the pointer from the G-sphere to fft-grid * 16 : !* pgfft(i) contains the phases of the G-vectors of sph. * 17 : !* * 18 : !************************************************************ 19 : USE m_types 20 : USE m_types_fftGrid 21 : IMPLICIT none 22 : 23 : INTEGER, INTENT(IN) :: isn 24 : TYPE(t_stars), INTENT(IN) :: stars 25 : REAL, INTENT(INOUT) :: afft(:) 26 : REAL, INTENT(INOUT) :: bfft(:) 27 : COMPLEX :: fg3(stars%ng3) !Sometimes we call this with an intent(in) variable if isn>0 (This is somewhat unsafe) 28 : LOGICAL, INTENT(IN), OPTIONAL :: scaled ! < determines if coefficients are scaled by stars%nstr 29 : 30 23888 : TYPE(t_fftgrid) :: fftgrid 31 11944 : call fftgrid%init((/3*stars%mx1,3*stars%mx2,3*stars%mx3/)) 32 : 33 2986 : IF (isn > 0) THEN 34 1174 : call fftgrid%putFieldOnGrid(stars,fg3) 35 : ELSE 36 68214048 : fftgrid%grid=cmplx(afft,bfft) 37 : ENDIF 38 : 39 2986 : call fftgrid%perform_fft(forward=(isn<0)) 40 : !---> now do the fft (isn=+1 : G -> r ; isn=-1 : r -> G) 41 : 42 2986 : if (isn >0) THEN 43 44163130 : afft = real(fftgrid%grid) 44 44163130 : bfft = aimag(fftgrid%grid) 45 : else 46 1812 : call fftgrid%takeFieldFromGrid(stars,fg3) 47 : !Scaling by stars%nstr is already done in previous call 48 1812 : IF (PRESENT(scaled)) THEN 49 0 : IF (.not.scaled) fg3 = fg3*stars%nstr 50 : ENDIF 51 : ENDIF 52 : 53 2986 : END SUBROUTINE fft3d 54 : END MODULE m_fft3d