|
您好,我算了一个4*4的数组,得到的结果和您类似,结果中也只显示了N/2+1的数据,N/2+1以后的数据都是0,通过对比matlab算的结果,发现偏差很大;
麻烦问一下,如果我要得到N/2+1以后的数据,应该怎么做呢??[Fortran] 纯文本查看 复制代码 010 | real , allocatable :: eta ( : , : ) , input ( : , : ) |
011 | complex , allocatable :: etak ( : , : ) , output ( : , : ) |
013 | allocate ( eta ( nx , ny ) , input ( nx , ny ) ) |
014 | allocate ( etak ( nx , ny ) , output ( nx , ny ) ) |
016 | eta = reshape ( [ 3 , 0 , -1 , 0 , & |
019 | 2 , -1 , 4 , 3 ] , shape ( eta ) ) |
030 | CALL sfftw_plan_dft_r 2 c_ 2 d ( p_up , nx , ny , input , output , FFTW_EXHAUSTIVE ) |
031 | CALL sfftw_plan_dft_c 2 r_ 2 d ( p_dn , nx , ny , output , input , FFTW_EXHAUSTIVE ) |
033 | call forward ( eta , etak ) |
044 | call backward ( etak , eta ) |
055 | deallocate ( eta , input ) |
056 | deallocate ( etak , output ) |
067 | integer , parameter :: Nx = 4 , Ny = 4 |
068 | integer ( kind = 8 ) :: p_up , p_dn |
073 | subroutine backward ( output , input ) |
079 | COMPLEX , INTENT ( IN ) :: output ( nx , ny ) |
080 | REAL , INTENT ( OUT ) :: input ( nx , ny ) |
081 | COMPLEX :: tempk ( nx , ny ) |
085 | sizescale = 1.0 / FLOAT ( nx * ny ) |
089 | tempk ( i , j ) = output ( i , j ) |
093 | CALL sfftw_execute_dft_c 2 r ( p_dn , tempk , input ) |
096 | input ( i , j ) = sizescale * input ( i , j ) |
100 | END subroutine backward |
103 | subroutine forward ( input , output ) |
109 | real , intent ( IN ) :: input ( nx , ny ) |
110 | complex , intent ( OUT ) :: output ( nx , ny ) |
112 | call sfftw_execute_dft_r 2 c ( p_up , input , output ) |
114 | end subroutine forward |
|
|