NCEPLIBS-ip 5.2.0
Loading...
Searching...
No Matches
spsynth.f
Go to the documentation of this file.
1C> @file
2C> @brief Synthesize Fourier coefficients from spectral coefficients.
3C>
4C> ### Program History Log
5C> Date | Programmer | Comments
6C> -----|------------|---------
7C> 91-10-31 | Mark Iredell | Initial.
8C> 1998-12-18 | Mark Iredell | Include scalar and gradient option.
9C>
10C> @author Iredell @date 92-10-31
11
12C> Synthesizes Fourier coefficients from spectral coefficients
13C> for a latitude pair (Northern and Southern hemispheres).
14C>
15C> Vector components are divided by cosine of latitude.
16C>
17C> @param I spectral domain shape
18C> (0 for triangular, 1 for rhomboidal)
19C> @param M spectral truncation
20C> @param IM even number of Fourier coefficients
21C> @param IX dimension of Fourier coefficients (IX>=IM+2)
22C> @param NC dimension of spectral coefficients
23C> (NC>=(M+1)*((I+1)*M+2))
24C> @param NCTOP dimension of spectral coefficients over top
25C> (NCTOP>=2*(M+1))
26C> @param KM number of fields
27C> @param CLAT cosine of latitude
28C> @param PLN ((M+1)*((I+1)*M+2)/2) Legendre polynomial
29C> @param PLNTOP Legendre polynomial over top
30C> @param SPC spectral coefficients
31C> @param SPCTOP spectral coefficients over top
32C> @param MP identifiers (0 for scalar, 1 for vector,
33C> or 10 for scalar and gradient)
34C> @param F Fourier coefficients for latitude pair
35C>
36C> @author Iredell @date 92-10-31
37 SUBROUTINE spsynth(I,M,IM,IX,NC,NCTOP,KM,CLAT,PLN,PLNTOP,MP,
38 & SPC,SPCTOP,F)
39
40 REAL PLN((M+1)*((I+1)*M+2)/2),PLNTOP(M+1)
41 INTEGER MP(KM)
42 REAL SPC(NC,KM),SPCTOP(NCTOP,KM)
43 REAL F(IX,2,KM)
44 REAL :: TINYREAL=tiny(1.0)
45
46C ZERO OUT FOURIER COEFFICIENTS.
47 DO k=1,km
48 DO l=0,im/2
49 f(2*l+1,1,k)=0.
50 f(2*l+2,1,k)=0.
51 f(2*l+1,2,k)=0.
52 f(2*l+2,2,k)=0.
53 ENDDO
54 ENDDO
55
56C SYNTHESIS OVER POLE.
57C INITIALIZE FOURIER COEFFICIENTS WITH TERMS OVER TOP OF THE SPECTRUM.
58C INITIALIZE EVEN AND ODD POLYNOMIALS SEPARATELY.
59 IF(abs(clat).LT.tinyreal) THEN
60 ltope=mod(m+1+i,2)
61!C$OMP PARALLEL DO PRIVATE(LB,LE,L,KS,KP,N,F1R,F1I)
62 DO k=1,km
63 lb=mp(k)
64 le=mp(k)
65 IF(mp(k).EQ.10) THEN
66 lb=0
67 le=1
68 ENDIF
69 l=lb
70 IF(l.EQ.1) THEN
71 IF(l.EQ.ltope) THEN
72 f(2*l+1,1,k)=plntop(l+1)*spctop(2*l+1,k)
73 f(2*l+2,1,k)=plntop(l+1)*spctop(2*l+2,k)
74 ELSE
75 f(2*l+1,2,k)=plntop(l+1)*spctop(2*l+1,k)
76 f(2*l+2,2,k)=plntop(l+1)*spctop(2*l+2,k)
77 ENDIF
78 ENDIF
79C FOR EACH ZONAL WAVENUMBER, SYNTHESIZE TERMS OVER TOTAL WAVENUMBER.
80C SYNTHESIZE EVEN AND ODD POLYNOMIALS SEPARATELY.
81 DO l=lb,le
82 ks=l*(2*m+(i-1)*(l-1))
83 kp=ks/2+1
84 DO n=l,i*l+m,2
85 f(2*l+1,1,k)=f(2*l+1,1,k)+pln(kp+n)*spc(ks+2*n+1,k)
86 f(2*l+2,1,k)=f(2*l+2,1,k)+pln(kp+n)*spc(ks+2*n+2,k)
87 ENDDO
88 DO n=l+1,i*l+m,2
89 f(2*l+1,2,k)=f(2*l+1,2,k)+pln(kp+n)*spc(ks+2*n+1,k)
90 f(2*l+2,2,k)=f(2*l+2,2,k)+pln(kp+n)*spc(ks+2*n+2,k)
91 ENDDO
92C SEPARATE FOURIER COEFFICIENTS FROM EACH HEMISPHERE.
93C ODD POLYNOMIALS CONTRIBUTE NEGATIVELY TO THE SOUTHERN HEMISPHERE.
94 f1r=f(2*l+1,1,k)
95 f1i=f(2*l+2,1,k)
96 f(2*l+1,1,k)=f1r+f(2*l+1,2,k)
97 f(2*l+2,1,k)=f1i+f(2*l+2,2,k)
98 f(2*l+1,2,k)=f1r-f(2*l+1,2,k)
99 f(2*l+2,2,k)=f1i-f(2*l+2,2,k)
100 ENDDO
101 ENDDO
102
103C SYNTHESIS OVER FINITE LATITUDE.
104C INITIALIZE FOURIER COEFFICIENTS WITH TERMS OVER TOP OF THE SPECTRUM.
105C INITIALIZE EVEN AND ODD POLYNOMIALS SEPARATELY.
106 ELSE
107 lx=min(m,im/2)
108 ltope=mod(m+1,2)
109 ltopo=1-ltope
110 le=1+i*ltope
111 lo=2-i*ltopo
112!C$OMP PARALLEL DO PRIVATE(L,KS,KP,N,F1R,F1I)
113 DO k=1,km
114 IF(mp(k).EQ.1) THEN
115 DO l=ltope,lx,2
116 f(2*l+1,le,k)=plntop(l+1)*spctop(2*l+1,k)
117 f(2*l+2,le,k)=plntop(l+1)*spctop(2*l+2,k)
118 ENDDO
119 DO l=ltopo,lx,2
120 f(2*l+1,lo,k)=plntop(l+1)*spctop(2*l+1,k)
121 f(2*l+2,lo,k)=plntop(l+1)*spctop(2*l+2,k)
122 ENDDO
123 ENDIF
124C FOR EACH ZONAL WAVENUMBER, SYNTHESIZE TERMS OVER TOTAL WAVENUMBER.
125C SYNTHESIZE EVEN AND ODD POLYNOMIALS SEPARATELY.
126 DO l=0,lx
127 ks=l*(2*m+(i-1)*(l-1))
128 kp=ks/2+1
129 DO n=l,i*l+m,2
130 f(2*l+1,1,k)=f(2*l+1,1,k)+pln(kp+n)*spc(ks+2*n+1,k)
131 f(2*l+2,1,k)=f(2*l+2,1,k)+pln(kp+n)*spc(ks+2*n+2,k)
132 ENDDO
133 DO n=l+1,i*l+m,2
134 f(2*l+1,2,k)=f(2*l+1,2,k)+pln(kp+n)*spc(ks+2*n+1,k)
135 f(2*l+2,2,k)=f(2*l+2,2,k)+pln(kp+n)*spc(ks+2*n+2,k)
136 ENDDO
137 ENDDO
138C SEPARATE FOURIER COEFFICIENTS FROM EACH HEMISPHERE.
139C ODD POLYNOMIALS CONTRIBUTE NEGATIVELY TO THE SOUTHERN HEMISPHERE.
140C DIVIDE VECTOR COMPONENTS BY COSINE LATITUDE.
141 DO l=0,lx
142 f1r=f(2*l+1,1,k)
143 f1i=f(2*l+2,1,k)
144 f(2*l+1,1,k)=f1r+f(2*l+1,2,k)
145 f(2*l+2,1,k)=f1i+f(2*l+2,2,k)
146 f(2*l+1,2,k)=f1r-f(2*l+1,2,k)
147 f(2*l+2,2,k)=f1i-f(2*l+2,2,k)
148 ENDDO
149 IF(mp(k).EQ.1) THEN
150 DO l=0,lx
151 f(2*l+1,1,k)=f(2*l+1,1,k)/clat
152 f(2*l+2,1,k)=f(2*l+2,1,k)/clat
153 f(2*l+1,2,k)=f(2*l+1,2,k)/clat
154 f(2*l+2,2,k)=f(2*l+2,2,k)/clat
155 ENDDO
156 ENDIF
157 ENDDO
158 ENDIF
159 END
subroutine spsynth(i, m, im, ix, nc, nctop, km, clat, pln, plntop, mp, spc, spctop, f)
Synthesizes Fourier coefficients from spectral coefficients for a latitude pair (Northern and Souther...
Definition spsynth.f:39