fft_at_k.f90 2.83 KB
Newer Older
Marco Govoni's avatar
Marco Govoni committed
1
!
2
! Copyright (C) 2015-2017 M. Govoni 
Marco Govoni's avatar
Marco Govoni committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
! This file is part of WEST.
!
! Contributors to this file: 
! Marco Govoni
!
!-----------------------------------------------------------------------
MODULE fft_at_k
  !-----------------------------------------------------------------------
  !
  ! Everything is done following dffts
  !
  USE kinds,                ONLY : DP
  USE fft_interfaces,       ONLY : fwfft,invfft
  USE fft_types,            ONLY : fft_type_descriptor
  !
  IMPLICIT NONE
  !
  PRIVATE
  !
  PUBLIC :: single_invfft_k, single_fwfft_k 
  !
  CONTAINS
  !
  !
  SUBROUTINE single_invfft_k(dfft,n,nx,a1,b,cdriver,igk)
Marco Govoni's avatar
Marco Govoni committed
33
34
    !
    USE gvecs,                ONLY : nls
Marco Govoni's avatar
Marco Govoni committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
    !
    ! INVFFT : G ---> R
    !
    ! INPUT  : n     = actual number of PW
    !          a1     = ONE COMPLEX arrays containing ONE COMPLEX functions in G space
    !          lda   = leading dimension of a1
    !          ldb   = leading dimension of b          
    ! OUTPUT : b     = ONE COMPLEX array containing ONE REAL functions in R space + 0
    !
    IMPLICIT NONE
    !
    ! I/O 
    !
    TYPE(fft_type_descriptor), INTENT(IN) :: dfft
    INTEGER,INTENT(IN) :: n, nx
    COMPLEX(DP),INTENT(IN) :: a1(nx)
    COMPLEX(DP),INTENT(OUT) :: b(dfft%nnr)
    CHARACTER(LEN=*),INTENT(IN) :: cdriver
    INTEGER,INTENT(IN),OPTIONAL :: igk(n)
    !
    ! Workspace
    !
    INTEGER :: ig
    !
    b=0.0_DP
    IF(PRESENT(igk)) THEN
       DO ig=1,n
          b(nls(igk(ig)))=a1(ig)
       ENDDO
    ELSE
       DO ig=1,n
          b(nls(ig))=a1(ig)
       ENDDO
    ENDIF
    !
    CALL invfft(cdriver,b,dfft)
    !
  END SUBROUTINE
  !
  !
  SUBROUTINE single_fwfft_k(dfft,n,nx,a,b1,cdriver,igk)
Marco Govoni's avatar
Marco Govoni committed
76
77
    !
    USE gvecs,                ONLY : nls
Marco Govoni's avatar
Marco Govoni committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
    !
    ! FWFFT : R ---> G
    !
    ! INPUT  : n     = actual number of PW
    !          a     = ONE COMPLEX array containing ONE REAL functions in R space + 0
    !          lda   = leading dimension of a
    !          ldb   = leading dimension of b1 
    ! OUTPUT : b1     = ONE COMPLEX array containing ONE COMPLEX functions in G space
    !
    IMPLICIT NONE
    !
    ! I/O 
    !
    TYPE(fft_type_descriptor), INTENT(IN) :: dfft
    INTEGER,INTENT(IN) :: n,nx
    COMPLEX(DP),INTENT(INOUT) :: a(dfft%nnr)
    COMPLEX(DP),INTENT(OUT) :: b1(nx)
    CHARACTER(LEN=*),INTENT(IN) :: cdriver
    INTEGER,INTENT(IN),OPTIONAL :: igk(n)
    !
    ! Workspace
    !
    INTEGER :: ig
    !
    CALL fwfft(cdriver, a, dfft)
    !
    b1=0.0_DP
    !
    IF(PRESENT(igk)) THEN 
       DO ig=1,n 
          b1(ig) = a(nls(igk(ig)))
       ENDDO
    ELSE
       DO ig=1,n 
          b1(ig) = a(nls(ig))
       ENDDO
    ENDIF
    !
  END SUBROUTINE
  !
END MODULE