Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7227 Discussions

Can't find the examples/dftf/ directory in my MKL install

brianreinhold
Novice
502 Views

I just installed the standalone MKL and it did not include the examples/dftf/ directory. The  MKL developers guide says it should exist. Where can I get these examples or are they now gone?

0 Kudos
1 Solution
Spencer_P_Intel
Employee
358 Views

Examples  live in the <mkl root>/share/doc/mkl/examples folder.  There you will find dftf/ folder by unpacking the examples_core_f.tgz archive (or equivalent if you are on Windows).

View solution in original post

0 Kudos
2 Replies
Spencer_P_Intel
Employee
359 Views

Examples  live in the <mkl root>/share/doc/mkl/examples folder.  There you will find dftf/ folder by unpacking the examples_core_f.tgz archive (or equivalent if you are on Windows).

0 Kudos
brianreinhold
Novice
21 Views

Thank you! It's good to have those. My plan routine compiled and built but was totally different than the example. I don't understand how it built.

After looking at the examples I changed my routine to

module Fftw3HelpersModule
    use, intrinsic :: iso_c_binding
    implicit none

    ! FFTW plan handles for different transforms
    integer*8 :: plan_spectral_to_grid_sin = 0
    integer*8 :: plan_grid_to_spectral_sin = 0
    integer*8 :: plan_spectral_to_grid_cos = 0
    integer*8 :: plan_grid_to_spectral_cos = 0
    integer*8 :: plan_spectral_to_grid_zonal_1d = 0
    integer*8 :: plan_grid_to_spectral_zonal_1d = 0

    contains

    subroutine setup_fftw_plans(Nx, Ny)
        use, intrinsic :: iso_c_binding
        implicit none

        include 'fftw3.f'
        include 'fftw3_mkl.f'

        integer(c_int), intent(in) :: Nx, Ny
        real(C_FLOAT), allocatable :: dummy(:, :)
        real(C_FLOAT), allocatable :: dummy_1d(:)

        ! Cleanup existing plans
        if (plan_spectral_to_grid_sin .NE. 0) call sfftw_destroy_plan(plan_spectral_to_grid_sin)
        if (plan_grid_to_spectral_sin .NE. 0) call sfftw_destroy_plan(plan_grid_to_spectral_sin)
        if (plan_spectral_to_grid_cos .NE. 0) call sfftw_destroy_plan(plan_spectral_to_grid_cos)
        if (plan_grid_to_spectral_cos .NE. 0) call sfftw_destroy_plan(plan_grid_to_spectral_cos)
        if (plan_spectral_to_grid_zonal_1d .NE. 0) call sfftw_destroy_plan(plan_spectral_to_grid_zonal_1d)
        if (plan_grid_to_spectral_zonal_1d .NE. 0) call sfftw_destroy_plan(plan_grid_to_spectral_zonal_1d)

        allocate(dummy(Ny, Nx))
        allocate(dummy_1d(Ny))

        ! Plans for sin(kx)sin(ly) and cos(kx)sin(ly) components
        call sfftw_plan_r2r_2d(plan_grid_to_spectral_sin, Ny, Nx, dummy, dummy, FFTW_RODFT00, FFTW_R2HC, FFTW_MEASURE) ! MKL_RODFT00
        call sfftw_plan_r2r_2d(plan_spectral_to_grid_sin, Ny, Nx, dummy, dummy, FFTW_RODFT00, FFTW_HC2R, FFTW_MEASURE)
        ! Plans for sin(kx)cos(ly) and cos(kx)cos(ly) components
        call sfftw_plan_r2r_2d(plan_grid_to_spectral_cos, Ny, Nx, dummy, dummy, FFTW_REDFT00, FFTW_R2HC, FFTW_MEASURE)
        call sfftw_plan_r2r_2d(plan_spectral_to_grid_cos, Ny, Nx, dummy, dummy, FFTW_REDFT00, FFTW_HC2R, FFTW_MEASURE)
        ! Plans for zonal flow components cos(ly).
        call sfftw_plan_r2r_1d(plan_grid_to_spectral_zonal_1d, Ny, dummy_1d, dummy_1d, FFTW_REDFT00, FFTW_MEASURE)
        call sfftw_plan_r2r_1d(plan_spectral_to_grid_zonal_1d, Ny, dummy_1d, dummy_1d, FFTW_REDFT00, FFTW_MEASURE)

        deallocate(dummy)
        deallocate(dummy_1d)
    end subroutine setup_fftw_plans

end module Fftw3HelpersModule

It was

module Fftw3HelpersModule
    use, intrinsic :: iso_c_binding
    implicit none

    include 'fftw3.f03' 

    ! FFTW plan handles for different transforms
    type(c_ptr) :: plan_spectral_to_grid_sin, plan_grid_to_spectral_sin
    type(c_ptr) :: plan_spectral_to_grid_cos, plan_grid_to_spectral_cos
    type(c_ptr) :: plan_spectral_to_grid_zonal_1d, plan_grid_to_spectral_zonal_1d

    contains

    subroutine setup_fftw_plans(Nx, Ny)
        use, intrinsic :: iso_c_binding
        implicit none

        include 'fftw3.f03'        

        integer(c_int), intent(in) :: Nx, Ny
        real(C_FLOAT), allocatable :: dummy(:, :)
        real(C_FLOAT), allocatable :: dummy_1d(:)

        ! Cleanup existing plans
        if (c_associated(plan_spectral_to_grid_sin)) call fftw_destroy_plan(plan_spectral_to_grid_sin)
        if (c_associated(plan_grid_to_spectral_sin)) call fftw_destroy_plan(plan_grid_to_spectral_sin)
        if (c_associated(plan_spectral_to_grid_cos)) call fftw_destroy_plan(plan_spectral_to_grid_cos)
        if (c_associated(plan_grid_to_spectral_cos)) call fftw_destroy_plan(plan_grid_to_spectral_cos)
        if (c_associated(plan_spectral_to_grid_zonal_1d)) call fftw_destroy_plan(plan_spectral_to_grid_zonal_1d)
        if (c_associated(plan_grid_to_spectral_zonal_1d)) call fftw_destroy_plan(plan_grid_to_spectral_zonal_1d)

        allocate(dummy(Ny, Nx))
        allocate(dummy_1d(Ny))

        ! Plans for sin(kx)sin(ly) and cos(kx)sin(ly) components
        plan_grid_to_spectral_sin = fftwf_plan_r2r_2d(Ny, Nx, dummy, dummy, FFTW_RODFT00, FFTW_R2HC, FFTW_MEASURE)
        plan_spectral_to_grid_sin = fftwf_plan_r2r_2d(Ny, Nx, dummy, dummy, FFTW_RODFT00, FFTW_HC2R, FFTW_MEASURE)
        ! Plans for sin(kx)cos(ly) and cos(kx)cos(ly) components
        plan_grid_to_spectral_cos = fftwf_plan_r2r_2d(Ny, Nx, dummy, dummy, FFTW_REDFT00, FFTW_R2HC, FFTW_MEASURE)
        plan_spectral_to_grid_cos = fftwf_plan_r2r_2d(Ny, Nx, dummy, dummy, FFTW_REDFT00, FFTW_HC2R, FFTW_MEASURE)
        ! Plans for zonal flow components cos(ly).
        plan_grid_to_spectral_zonal_1d = fftwf_plan_r2r_1d(Ny, dummy_1d, dummy_1d, FFTW_REDFT00, FFTW_MEASURE)
        plan_spectral_to_grid_zonal_1d = fftwf_plan_r2r_1d(Ny, dummy_1d, dummy_1d, FFTW_REDFT00, FFTW_MEASURE)

        deallocate(dummy)
        deallocate(dummy_1d)
    end subroutine setup_fftw_plans

end module Fftw3HelpersModule

 I am assuming the changes I made to follow the examples are correct.

0 Kudos
Reply