Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program main
- complex(8),allocatable::array(:,:)
- allocate(array(17, 17))
- array = 1.0d0
- call fft(array(1:16,1:16))
- contains
- subroutine fft(a)
- use mkl_dfti
- implicit none
- complex(8),intent(inout)::a(:,:)
- type(dfti_descriptor),pointer::desc
- integer::stat
- stat = DftiCreateDescriptor(desc, DFTI_DOUBLE, DFTI_COMPLEX, 2, shape(a) )
- stat = DftiCommitDescriptor(desc)
- stat = DftiComputeForward(desc, a(:,1))
- stat = DftiFreeDescriptor(desc)
- end subroutine
- end program
- program main
- implicit none
- real(8),allocatable::a(:,:)
- pause
- allocate(a(8192,8192))
- pause
- call random_number(a)
- pause
- call foo(a(:4096,:4096))
- pause
- contains
- subroutine foo(a)
- implicit none
- real(8)::a(:,:)
- open(unit=16, file='a_sum.txt')
- write(16, *) sum(a)
- close(16)
- end subroutine
- end program
- module m_foo
- implicit none
- contains
- subroutine foo(a)
- implicit none
- real(8),contiguous::a(:,:)
- integer::i, j
- open(unit=16, file='a_sum.txt')
- write(16, *) sum(a)
- close(16)
- call nointerface(a)
- end subroutine
- end module
- subroutine nointerface(a)
- implicit none
- real(8)::a(*)
- end subroutine
- program main
- use m_foo
- implicit none
- integer,parameter::N = 8192
- real(8),allocatable::a(:,:)
- integer::i, j
- real(8)::count
- pause
- allocate(a(N, N))
- pause
- call random_number(a)
- pause
- call foo(a(:N/2,:N/2))
- pause
- end program
- program main
- implicit none
- complex(8),allocatable::a(:,:)
- allocate(a(16,16))
- a = 0.0d0
- a(1:4,1:4) = 1.0d0
- call fft(a(1:4,1:4))
- write(*,*) a(1:4,1:4)
- pause
- a = 0.0d0
- a(1:4,1:4) = 1.0d0
- call fft_stride(a(1:4,1:4), 1, 16)
- write(*,*) a(1:4,1:4)
- pause
- contains
- subroutine fft(a) !{{{
- use mkl_dfti
- implicit none
- complex(8),intent(inout)::a(:,:)
- type(dfti_descriptor),pointer::desc
- integer::stat
- stat = DftiCreateDescriptor(desc, DFTI_DOUBLE, DFTI_COMPLEX, 2, shape(a) )
- stat = DftiCommitDescriptor(desc)
- stat = DftiComputeForward(desc, a(:,1))
- stat = DftiFreeDescriptor(desc)
- end subroutine !}}}
- subroutine fft_stride(a, s1, s2) !{{{
- use mkl_dfti
- implicit none
- complex(8),intent(inout)::a(:,:)
- integer::s1, s2
- type(dfti_descriptor),pointer::desc
- integer::stat
- integer::strides(3)
- strides = [0, s1, s2]
- stat = DftiCreateDescriptor(desc, DFTI_DOUBLE, DFTI_COMPLEX, 2, shape(a) )
- stat = DftiSetValue(desc, DFTI_INPUT_STRIDES, strides)
- stat = DftiCommitDescriptor(desc)
- stat = DftiComputeForward(desc, a(:,1))
- stat = DftiFreeDescriptor(desc)
- end subroutine !}}}
- end program
- program ...
- call fft(4,4,a(1:4,1:4))
- end program
- subroutine fft(m,n,a) !{{{
- use mkl_dfti
- implicit none
- complex(8),intent(inout)::a(*)
- integer :: m, n
- type(dfti_descriptor),pointer::desc
- integer::stat
- stat = DftiCreateDescriptor(desc, DFTI_DOUBLE, DFTI_COMPLEX, 2, (/m,n/) )
- stat = DftiCommitDescriptor(desc)
- stat = DftiComputeForward(desc, a)
- stat = DftiFreeDescriptor(desc)
- end subroutine !}}}
- program ...
- call fft_strided(4,4,a,16)
- end program
- subroutine fft_strided(m,n,a,lda) !{{{
- use mkl_dfti
- implicit none
- complex(8),intent(inout)::a(*)
- integer :: m, n, lda
- type(dfti_descriptor),pointer::desc
- integer::stat
- integer::strides(3)
- strides = [0, 1, lda]
- stat = DftiCreateDescriptor(desc, DFTI_DOUBLE, DFTI_COMPLEX, 2, (/m,n/) )
- stat = DftiSetValue(desc, DFTI_INPUT_STRIDES, strides)
- stat = DftiCommitDescriptor(desc)
- stat = DftiComputeForward(desc, a)
- stat = DftiFreeDescriptor(desc)
- end subroutine !}}}
- integer, dimension(10:20) :: array
- integer :: i
- array = [ (i, i=10,20) ]
- call foo(array(10:20:2))
- subroutine foo(a)
- integer, dimension(:) :: a
- integer :: i
- print*, lbound(a), ubound(a)
- do i=lbound(a,1), ubound(a,2)
- print*, a(i)
- end do
- end subroutine foo
- 1 6
- 10 12 14 16 18 20
- integer, dimension(10:) :: a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement