1 | !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC |
---|
2 | ! |
---|
3 | ! FFTPACK 5.0 |
---|
4 | ! Copyright (C) 1995-2004, Scientific Computing Division, |
---|
5 | ! University Corporation for Atmospheric Research |
---|
6 | ! Licensed under the GNU General Public License (GPL) |
---|
7 | ! |
---|
8 | ! Authors: Paul N. Swarztrauber and Richard A. Valent |
---|
9 | ! |
---|
10 | ! $Id: costb1.f,v 1.2 2004/06/15 21:14:57 rodney Exp $ |
---|
11 | ! |
---|
12 | !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC |
---|
13 | |
---|
14 | SUBROUTINE COSTB1(N,INC,X,WSAVE,WORK,IER) |
---|
15 | REAL X(INC,*) ,WSAVE(*) |
---|
16 | DOUBLE PRECISION DSUM |
---|
17 | IER = 0 |
---|
18 | NM1 = N-1 |
---|
19 | NP1 = N+1 |
---|
20 | NS2 = N/2 |
---|
21 | IF (N-2) 106,101,102 |
---|
22 | 101 X1H = X(1,1)+X(1,2) |
---|
23 | X(1,2) = X(1,1)-X(1,2) |
---|
24 | X(1,1) = X1H |
---|
25 | RETURN |
---|
26 | 102 IF (N .GT. 3) GO TO 103 |
---|
27 | X1P3 = X(1,1)+X(1,3) |
---|
28 | X2 = X(1,2) |
---|
29 | X(1,2) = X(1,1)-X(1,3) |
---|
30 | X(1,1) = X1P3+X2 |
---|
31 | X(1,3) = X1P3-X2 |
---|
32 | RETURN |
---|
33 | 103 X(1,1) = X(1,1)+X(1,1) |
---|
34 | X(1,N) = X(1,N)+X(1,N) |
---|
35 | DSUM = X(1,1)-X(1,N) |
---|
36 | X(1,1) = X(1,1)+X(1,N) |
---|
37 | DO 104 K=2,NS2 |
---|
38 | KC = NP1-K |
---|
39 | T1 = X(1,K)+X(1,KC) |
---|
40 | T2 = X(1,K)-X(1,KC) |
---|
41 | DSUM = DSUM+WSAVE(KC)*T2 |
---|
42 | T2 = WSAVE(K)*T2 |
---|
43 | X(1,K) = T1-T2 |
---|
44 | X(1,KC) = T1+T2 |
---|
45 | 104 END DO |
---|
46 | MODN = MOD(N,2) |
---|
47 | IF (MODN .EQ. 0) GO TO 124 |
---|
48 | X(1,NS2+1) = X(1,NS2+1)+X(1,NS2+1) |
---|
49 | 124 LENX = INC*(NM1-1) + 1 |
---|
50 | LNSV = NM1 + INT(LOG(REAL(NM1))) + 4 |
---|
51 | LNWK = NM1 |
---|
52 | ! |
---|
53 | CALL RFFT1F(NM1,INC,X,LENX,WSAVE(N+1),LNSV,WORK, & |
---|
54 | & LNWK,IER1) |
---|
55 | IF (IER1 .NE. 0) THEN |
---|
56 | IER = 20 |
---|
57 | CALL XERFFT ('COSTB1',-5) |
---|
58 | RETURN |
---|
59 | ENDIF |
---|
60 | ! |
---|
61 | FNM1S2 = FLOAT(NM1)/2. |
---|
62 | DSUM = .5*DSUM |
---|
63 | X(1,1) = FNM1S2*X(1,1) |
---|
64 | IF(MOD(NM1,2) .NE. 0) GO TO 30 |
---|
65 | X(1,NM1) = X(1,NM1)+X(1,NM1) |
---|
66 | 30 FNM1S4 = FLOAT(NM1)/4. |
---|
67 | DO 105 I=3,N,2 |
---|
68 | XI = FNM1S4*X(1,I) |
---|
69 | X(1,I) = FNM1S4*X(1,I-1) |
---|
70 | X(1,I-1) = DSUM |
---|
71 | DSUM = DSUM+XI |
---|
72 | 105 END DO |
---|
73 | IF (MODN .NE. 0) RETURN |
---|
74 | X(1,N) = DSUM |
---|
75 | 106 RETURN |
---|
76 | END |
---|