SURFEX v8.1
General documentation of Surfex
sufftp.F90
Go to the documentation of this file.
1 SUBROUTINE sufftp(KDLON,KFFTP0,LDODD)
2 
3 !**** *SUFFTP* - Initialize possible numbers for FFT's
4 
5 ! Purpose.
6 ! --------
7 ! Initialize possible numbers for FFT's
8 
9 !** Interface.
10 ! ----------
11 ! *CALL* *SUFFTP(KDLON,KFFTP0)
12 
13 ! Explicit arguments :
14 ! --------------------
15 ! LDODD : .TRUE. if odd numbers are allowed
16 ! KFFTP0(KDLON) 0 ---> possible for FFT
17 ! 1 ---> impossible for FFT
18 
19 ! Implicit arguments :
20 ! --------------------
21 
22 ! Method.
23 ! -------
24 ! See documentation
25 
26 ! Externals. none.
27 ! ----------
28 
29 ! Reference.
30 ! ----------
31 ! ARPEGE documentation
32 
33 ! Author.
34 ! -------
35 ! Philippe Courtier *DMN*
36 
37 ! Modifications.
38 ! --------------
39 ! Creation of cycle 4
40 ! R. El Khatib 15-May-2013 Option to allow or not odd numbers
41 ! ------------------------------------------------------------------
42 
43 
44 USE parkind1 ,ONLY : jpim ,jprb
45 USE yomhook ,ONLY : lhook, dr_hook
46 
47 IMPLICIT NONE
48 
49 INTEGER(KIND=JPIM), INTENT(IN) :: KDLON
50 INTEGER(KIND=JPIM), INTENT(OUT) :: KFFTP0(kdlon)
51 LOGICAL, INTENT(IN) :: LDODD
52 
53 INTEGER(KIND=JPIM) :: I2MAX, I3MAX, I5MAX, IMIN, IN, J, J2, J3, J5
54 
55 
56 REAL(KIND=JPRB) :: ZHOOK_HANDLE
57 
58 ! ------------------------------------------------------------------
59 
60 IF (lhook) CALL dr_hook('REDUCED_GRID',0,zhook_handle)
61 
62 !* 1. Initialize up to IMIN-1
63 ! --------------------
64 
65 imin=16
66 IF(kdlon <= imin-1)THEN
67  CALL abor1(' ERROR IN SUFFTP0 ')
68 ENDIF
69 
70 DO j=1,imin-1
71  kfftp0(j)=1
72 ENDDO
73 
74 ! ------------------------------------------------------------------
75 
76 !* 2. Initialize from 16.
77 ! -------------------
78 
79 i2max=int(log(REAL(kdlon,jprb))/log(2._JPRB))+1
80 i3max=int(log(REAL(kdlon,jprb))/log(3._JPRB))+1
81 i5max=int(log(REAL(kdlon,jprb))/log(5._JPRB))+1
82 
83 DO j=imin,kdlon
84 
85  IF (.NOT.ldodd) THEN
86  IF(mod(j,2) /= 0)THEN
87  kfftp0(j)=1
88  GOTO 202
89  ENDIF
90  ENDIF
91 
92  in=j
93  DO j2=1,i2max
94  IF(mod(in,2) == 0)THEN
95  in=in/2
96  ENDIF
97  ENDDO
98 
99  DO j3=1,i3max
100  IF(mod(in,3) == 0)THEN
101  in=in/3
102  ENDIF
103  ENDDO
104 
105  DO j5=1,i5max
106  IF(mod(in,5) == 0)THEN
107  in=in/5
108  ENDIF
109  ENDDO
110 
111  IF(in /= 1)THEN
112  kfftp0(j)=1
113  ELSE
114  kfftp0(j)=0
115  ENDIF
116  202 CONTINUE
117 ENDDO
118 
119 ! Memo :
120 ! this is old stuff and is not used anymore, unfortunately some resolutions like T799 have been created like this !!
121 ! The possibility of 625 or 1250 points in the T426, TL639 grids
122 ! should be eliminated due to the radiation code (memo from Lars)
123 !IF(KDLON >= 640) THEN
124 ! KFFTP0(625)=1
125 ! IF(KDLON >= 1250) THEN
126 ! KFFTP0(1250)=1
127 ! ENDIF
128 !ENDIF
129 
130 IF (lhook) CALL dr_hook('REDUCED_GRID',1,zhook_handle)
131 
132 END SUBROUTINE sufftp
integer, parameter jpim
Definition: parkind1.F90:13
subroutine abor1(CDTEXT)
Definition: abor1.F90:2
integer, parameter jprb
Definition: parkind1.F90:32
logical lhook
Definition: yomhook.F90:15
subroutine sufftp(KDLON, KFFTP0, LDODD)
Definition: sufftp.F90:2