NCEPLIBS-ip 5.2.0
Loading...
Searching...
No Matches
splegend.f
Go to the documentation of this file.
1C> @file
2C>
3C> Compute Legendre polynomials
4C> @author IREDELL @date 92-10-31
5
6C> Evaluates the orthonormal associated Legendre polynomials in the
7C> spectral domain at a given latitude. Subprogram splegend should
8C> be called already. If l is the zonal wavenumber, N is the total
9C> wavenumber, and EPS(L,N)=SQRT((N**2-L**2)/(4*N**2-1)) then the
10C> following bootstrapping formulas are used:
11C>
12C> <pre>
13C> PLN(0,0)=SQRT(0.5)
14C> PLN(L,L)=PLN(L-1,L-1)*CLAT*SQRT(FLOAT(2*L+1)/FLOAT(2*L))
15C> PLN(L,N)=(SLAT*PLN(L,N-1)-EPS(L,N-1)*PLN(L,N-2))/EPS(L,N)
16C> </pre>
17C>
18C> Synthesis at the pole needs only two zonal wavenumbers. Scalar
19C> fields are synthesized with zonal wavenumber 0 while vector
20C> fields are synthesized with zonal wavenumber 1. (Thus polar
21C> vector fields are implicitly divided by clat.) The following
22C> bootstrapping formulas are used at the pole:
23C>
24C> <pre>
25C> PLN(0,0)=SQRT(0.5)
26C> PLN(1,1)=SQRT(0.75)
27C> PLN(L,N)=(PLN(L,N-1)-EPS(L,N-1)*PLN(L,N-2))/EPS(L,N)
28C> </pre>
29C>
30C> PROGRAM HISTORY LOG:
31C> - 91-10-31 MARK IREDELL
32C> - 98-06-10 MARK IREDELL GENERALIZE PRECISION
33C>
34C> @param I - INTEGER SPECTRAL DOMAIN SHAPE
35C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
36C> @param M - INTEGER SPECTRAL TRUNCATION
37C> @param SLAT - REAL SINE OF LATITUDE
38C> @param CLAT - REAL COSINE OF LATITUDE
39C> @param EPS - REAL ((M+1)*((I+1)*M+2)/2) SQRT((N**2-L**2)/(4*N**2-1))
40C> @param EPSTOP - REAL (M+1) SQRT((N**2-L**2)/(4*N**2-1)) OVER TOP
41C> @param[out] PLN - REAL ((M+1)*((I+1)*M+2)/2) LEGENDRE POLYNOMIAL
42C> @param[out] PLNTOP - REAL (M+1) LEGENDRE POLYNOMIAL OVER TOP
43C>
44 SUBROUTINE splegend(I,M,SLAT,CLAT,EPS,EPSTOP,PLN,PLNTOP)
45
46CFPP$ NOCONCUR R
47 REAL EPS((M+1)*((I+1)*M+2)/2),EPSTOP(M+1)
48 REAL PLN((M+1)*((I+1)*M+2)/2),PLNTOP(M+1)
49 REAL(KIND=selected_real_kind(15,45)):: dln((m+1)*((i+1)*m+2)/2)
50 REAL :: TINYREAL=tiny(1.0), rdln1, rdln2
51C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
52C ITERATIVELY COMPUTE PLN WITHIN SPECTRAL DOMAIN AT POLE
53 m1=m+1
54 m2=2*m+i+1
55 mx=(m+1)*((i+1)*m+2)/2
56 IF(abs(clat).LT.tinyreal) THEN
57 dln(1)=sqrt(0.5)
58 IF(m.GT.0) THEN
59 dln(m1+1)=sqrt(0.75)
60 dln(2)=slat*dln(1)/eps(2)
61 ENDIF
62 IF(m.GT.1) THEN
63 dln(m1+2)=slat*dln(m1+1)/eps(m1+2)
64 dln(3)=(slat*dln(2)-eps(2)*dln(1))/eps(3)
65 DO n=3,m
66 k=1+n
67 dln(k)=(slat*dln(k-1)-eps(k-1)*dln(k-2))/eps(k)
68 k=m1+n
69 dln(k)=(slat*dln(k-1)-eps(k-1)*dln(k-2))/eps(k)
70 ENDDO
71 IF(i.EQ.1) THEN
72 k=m2
73 dln(k)=(slat*dln(k-1)-eps(k-1)*dln(k-2))/eps(k)
74 ENDIF
75 DO k=m2+1,mx
76 dln(k)=0.
77 ENDDO
78 ENDIF
79C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
80C COMPUTE POLYNOMIALS OVER TOP OF SPECTRAL DOMAIN
81 k=m1+1
82 rdln1=real(dln(k-1))
83 rdln2=real(dln(k-2))
84 plntop(1)=(slat*rdln1-eps(k-1)*rdln2)/epstop(1)
85 IF(m.GT.0) THEN
86 k=m2+1
87 rdln1=real(dln(k-1))
88 rdln2=real(dln(k-2))
89 plntop(2)=(slat*rdln1-eps(k-1)*rdln2)/epstop(2)
90 DO l=2,m
91 plntop(l+1)=0.
92 ENDDO
93 ENDIF
94C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
95C ITERATIVELY COMPUTE PLN(L,L) (BOTTOM HYPOTENUSE OF DOMAIN)
96 ELSE
97 nml=0
98 k=1
99 dln(k)=sqrt(0.5)
100 DO l=1,m+(i-1)*nml
101 kp=k
102 k=l*(2*m+(i-1)*(l-1))/2+l+nml+1
103 dln(k)=dln(kp)*clat*sqrt(float(2*l+1)/float(2*l))
104 ENDDO
105C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106C COMPUTE PLN(L,L+1) (DIAGONAL NEXT TO BOTTOM HYPOTENUSE OF DOMAIN)
107 nml=1
108CDIR$ IVDEP
109 DO l=0,m+(i-1)*nml
110 k=l*(2*m+(i-1)*(l-1))/2+l+nml+1
111 dln(k)=slat*dln(k-1)/eps(k)
112 ENDDO
113C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
114C COMPUTE REMAINING PLN IN SPECTRAL DOMAIN
115 DO nml=2,m
116CDIR$ IVDEP
117 DO l=0,m+(i-1)*nml
118 k=l*(2*m+(i-1)*(l-1))/2+l+nml+1
119 dln(k)=(slat*dln(k-1)-eps(k-1)*dln(k-2))/eps(k)
120 ENDDO
121 ENDDO
122C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
123C COMPUTE POLYNOMIALS OVER TOP OF SPECTRAL DOMAIN
124 DO l=0,m
125 nml=m+1+(i-1)*l
126 k=l*(2*m+(i-1)*(l-1))/2+l+nml+1
127 rdln1=real(dln(k-1))
128 rdln2=real(dln(k-2))
129 plntop(l+1)=(slat*rdln1-eps(k-1)*rdln2)/epstop(l+1)
130 ENDDO
131 ENDIF
132C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
133C RETURN VALUES
134 DO k=1,mx
135 pln(k)=real(dln(k))
136 ENDDO
137 RETURN
138 END
subroutine splegend(i, m, slat, clat, eps, epstop, pln, plntop)
Evaluates the orthonormal associated Legendre polynomials in the spectral domain at a given latitude.
Definition splegend.f:45