{"id":168,"date":"2020-02-25T16:14:33","date_gmt":"2020-02-25T08:14:33","guid":{"rendered":"https:\/\/www.yemeng.site\/?p=168"},"modified":"2020-02-26T12:06:26","modified_gmt":"2020-02-26T04:06:26","slug":"small-box-fft%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%ef%bc%88%e5%9b%9b%ef%bc%89%ef%bc%9afft","status":"publish","type":"post","link":"https:\/\/ru.yemeng.site\/?p=168","title":{"rendered":"Small Box FFT\u5b66\u4e60\u7b14\u8bb0\uff08\u56db\uff09\uff1aFFT"},"content":{"rendered":"\n<p>\u672c\u7bc7\u4e3b\u8981\u4ecb\u7ecd\u7a0b\u5e8f\u4e2d\u5e95\u5c42FFT\u8c03\u7528\uff0c\u4e3b\u8981\u53c2\u8003\u7684\u662fFFTP.f90\u6587\u4ef6\uff08\u4e32\u884c\u7248\u672c\u662fFFTS.f90\uff09\u4e2d\u7684Fourier_new\u6a21\u5757\u3002<\/p>\n\n\n\n<p>\u7a0b\u5e8f\u4e2d\u5b9e\u9645\u662f\u8c03\u7528FFTW\u5e93\uff0c\u7531\u4e8e\u5728Fortran 03\u4ee5\u540e\u7684\u7248\u672c\u4e2d\u53ef\u4ee5\u4f7f\u7528C\u8bed\u8a00API\uff0c\u8fd9\u4e5f\u662fFFTW\u9f13\u52b1\u7684\u505a\u6cd5\uff08\u53c2\u8003<a href=\"http:\/\/fftw.org\/doc\/Calling-FFTW-from-Modern-Fortran.html\">FFTW\u5b98\u65b9\u6587\u6863<\/a>\uff09\uff0c\u4e3a\u6b64\u9700\u8981\u5728\u5f00\u5934\u52a0\u5165\u4e00\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"fortran\" class=\"language-fortran\">use, intrinsic :: iso_c_binding<\/code><\/pre>\n\n\n\n<p>\u7a0b\u5e8f\u4e2d\u5c06FFT\u76f8\u5173\u7684\u4fe1\u606f\u5c01\u88c5\u6210\u4e86\u4e00\u4e2aFFT_CONFIG\u6570\u636e\u7c7b\u578b\uff0c\u5176\u5b9a\u4e49\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"fortran\" class=\"language-fortran\">type FFT_CONFIG\n\tcharacter(len=4) \t\t\t\t\t\t\t\t\t\t\tid \t\t\t\t\t\t\t\t\t! \u6807\u8bb0\uff0c\u4f8b\u5982DGBX\u3001DSBX\n\tinteger \t\t\t\t\t\t\t\t\t\t\t\t\tfftAlgo \t\t\t\t\t\t\t! FFT\u8ba1\u7b97\u6a21\u5f0f\n\tinteger(c_intptr_t) \t\t\t\t\t\t\t\t\t\ttotalDimX, totalDimX, totalDimZ \t! \u4e09\u4e2a\u65b9\u5411\u7684\u9636\u6570\n\tinteger(c_intptr_t) \t\t\t\t\t\t\t\t\t\tlocalDimZ \t\t\t\t\t\t\t! z\u65b9\u5411\u7684\u5c40\u57df\u9636\u6570\n\tinteger(c_intptr_t) \t\t\t\t\t\t\t\t\t\tlocalDimZOff\n\tinteger \t\t\t\t\t\t\t\t\t\t\t\t\tiCountFFT \t\t\t\t\t\t\t! FFT\u8ba1\u6570\u5668\n\tinteger \t\t\t\t\t\t\t\t\t\t\t\t\toffset\n\treal*8 \t\t\t\t\t\t\t\t\t\t\t\t\t\tnormConst \t\t\t\t\t\t\t! \u5982\u679c\u5b9a\u4e49\u4e86FFT_NORM_EXACT\uff0c\u5219\u7c7b\u578b\u4e3ainteger*8\n\ttype(c_ptr) \t\t\t\t\t\t\t\t\t\t\t\tfftw3GlobFWD,fftw3GlobBWD\n\ttype(c_ptr) \t\t\t\t\t\t\t\t\t\t\t\tcdata\n\treal(c_double), pointer, dimension( *, *, * ) \t\t\t\tin \t\t\t\t\t\t\t\t\t! \u6307\u5411\u5b9e\u7a7a\u95f4\u6570\u7ec4\u7684\u6307\u9488\n\tcomplex(c_double_complex), pointer, dimension( *, *, * ) \tout \t\t\t\t\t\t\t\t! \u6307\u5411\u5012\u7a7a\u95f4\u6570\u7ec4\u7684\u6307\u9488\nend type FFT_CONFIG<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u5176\u4e2d\u4f7f\u7528\u4e86\u8bf8\u5982c_intptr_t\u548cc_double\u8fd9\u6837\u7684\u6570\u636e\u7c7b\u578b\u3002\u57fa\u4e8e\u8fd9\u4e00\u6570\u636e\u7c7b\u578b\uff0c\u5b9a\u4e49\u4e86\u4e00\u4e2a\u7edf\u4e00\u7684FFT_NEW\u63a5\u53e3\u7528\u4e8e\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u7684\u6b63\u5411\u548c\u9006\u5411\u5085\u91cc\u53f6\u53d8\u6362\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"fortran\" class=\"language-fortran\">interface FFT_NEW\n\tmodule procedure \tForwardFFT_4D\n\tmodule procedure \tBackFFT_4D\n\tmodule procedure \tForwardFFT_3D\n\tmodule procedure \tBackFFT_3D\nend interface<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u901a\u8fc7\u8f93\u5165\u53c2\u6570\u7684\u7c7b\u578b\u6765\u9009\u62e9\u4f7f\u7528\u7684\u5177\u4f53\u5b50\u7a0b\u5e8f\uff0c\u4f8b\u5982\u5f53\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u5b9e\u4e09\u7ef4\u6570\u7ec4\u800c\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u590d\u4e09\u7ef4\u6570\u7ec4\u65f6\uff08\u7b2c\u4e00\u4e2a\u53c2\u6570\u662fFFT_CONFIG\u7c7b\u578b\uff09\u5219\u8c03\u7528ForwardFFT_3D\u3002\u7531\u4e8e\u4f7f\u7528\u7684\u662fFFTW\u5e93\uff0c\u5728\u5b9e\u9645\u8ba1\u7b97\u524d\u9700\u8981\u5efa\u7acb\u4e00\u4e2aFFTW_PLAN\uff0c\u6a21\u5757\u91cc\u5b9a\u4e49\u4e86\u4e00\u4e2aPlanFFT_NEW\u5b50\u7a0b\u5e8f\u7528\u4e8e\u521d\u59cb\u5316\u5e76\u521b\u5efa FFTW_PLAN \uff0c\u5176\u5b9a\u4e49\u4e3a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"fortran\" class=\"language-fortran\">subroutine PlanFFT_NEW(\n\tinteger \t\t\tMPI_COMM,\n\ttype(FFT_CONFIG) \tconfig,\n\tinteger \t\t\tmode,\n\tinteger \t\t\tdimX,dimY,dimZ\n\t)<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91ccmode\u662f\u9009\u62e9\u521b\u5efaFFTW_PLAN\u7684\u65b9\u5f0f\uff0c\u8fd9\u4e00\u5b50\u7a0b\u5e8f\u4e2d\u5173\u952e\u7684\u8c03\u7528\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"fortran\" class=\"language-fortran\">totalLocalSize = fftw_mpi_local_size_3d( config%totalDimZ, config%totalDimY, config%totalDimX\/2+1, MPI_COMM, config%localDimZ, config%localDimZOff )\nconfig%cdata = fftw_alloc_complex( totalLocalSize )\n\ncall c_f_pointer( config%cdata, config%in, [2*(config%totalDimX\/2+1), config%totalDimY, config%localDimZ] )\ncall c_f_pointer( config%cdata, config%out, [config%totalDimX\/2+1, config%totalDimY, config%localDimZ] )\n\n\nconfig%fftw3GlobFWD = fftw_mpi_plan_dft_r2c_3d( config%totalDimZ, config%totalDimY, config%totalDimX, config%in, config%out, MPI_COMM, planDepth)\nconfig%fftw3GlobBWD = fftw_mpi_plan_dft_c2r_3d( config%totalDimZ, config%totalDimY, config%totalDimX, config%out, config%in, MPI_COMM, planDepth )<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u7684planDepth\u662f\u7531\u8f93\u5165\u53c2\u6570mode\u51b3\u5b9a\u3002\u6700\u540e\uff0c\u6211\u4eec\u4ee5ForwardFFT_3D\u4e3a\u4f8b\u6765\u8bf4\u660e\u5982\u4f55\u8c03\u7528FFTW\u5e93\u4e2d\u7684\u8fdb\u884c\u8ba1\u7b97\uff0c\u8fd9\u4e00\u5b50\u7a0b\u5e8f\u7684\u5b9a\u4e49\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"fortran\" class=\"language-fortran\">subroutine ForwardFFT_3D(\n\ttype(FFT_CONFIG) \t\t\t\t\tconfig,\n\treal*8, dimension( *, *, * ) \t\tarray,\n\tcomplex*8, dimension( *, *, * ) \ttransform\n\t)<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e00\u5b50\u7a0b\u5e8f\u9996\u5148\u5c06\u8f93\u5165\u7684\u6570\u7ec4array\u4f20\u5165config%in\uff0c\u5e76\u8fdb\u884c\u5982\u4e0b\u8c03\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"fortran\" class=\"language-fortran\">call fftw_mpi_execute_dft_r2c( config%fftw3GlobFWD, config%in, config%out )<\/code><\/pre>\n\n\n\n<p>\u518d\u5c06config%out\u4f20\u5230\u8f93\u51fa\u6570\u7ec4transform\uff0c\u5c31\u5b8c\u6210\u4e86array\u5230transform\u7684\uff08\u6b63\u5411\uff09FFT\u8ba1\u7b97\u3002\u6ce8\u610f\u8fd9\u91cc\u6240\u6709\u4e2d\u7684DFT\u6307\u7684\u662f\u79bb\u6563\u5085\u91cc\u53f6\u53d8\u6362\u800c\u975e\u5bc6\u5ea6\u6cdb\u51fd\u7406\u8bba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u7bc7\u4e3b\u8981\u4ecb\u7ecd\u7a0b\u5e8f\u4e2d\u5e95\u5c42FFT\u8c03\u7528\uff0c\u4e3b\u8981\u53c2\u8003\u7684\u662fFFTP.f90\u6587\u4ef6\uff08\u4e32\u884c\u7248\u672c\u662fFFTS.f90\uff09\u4e2d\u7684Fouri [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,9,6],"tags":[8,5],"class_list":["post-168","post","type-post","status-publish","format-standard","hentry","category-7","category-9","category-6","tag-fortran","tag-small-box-fft"],"_links":{"self":[{"href":"https:\/\/ru.yemeng.site\/index.php?rest_route=\/wp\/v2\/posts\/168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ru.yemeng.site\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ru.yemeng.site\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ru.yemeng.site\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ru.yemeng.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=168"}],"version-history":[{"count":13,"href":"https:\/\/ru.yemeng.site\/index.php?rest_route=\/wp\/v2\/posts\/168\/revisions"}],"predecessor-version":[{"id":220,"href":"https:\/\/ru.yemeng.site\/index.php?rest_route=\/wp\/v2\/posts\/168\/revisions\/220"}],"wp:attachment":[{"href":"https:\/\/ru.yemeng.site\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ru.yemeng.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ru.yemeng.site\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}