NCEPLIBS-ip  5.1.0
splegend.f
Go to the documentation of this file.
1 C> @file
2 C>
3 C> Compute Legendre polynomials
4 C> @author IREDELL @date 92-10-31
5 
6 C> Evaluates the orthonormal associated Legendre polynomials in the
7 C> spectral domain at a given latitude. Subprogram splegend should
8 C> be called already. If l is the zonal wavenumber, N is the total
9 C> wavenumber, and EPS(L,N)=SQRT((N**2-L**2)/(4*N**2-1)) then the
10 C> following bootstrapping formulas are used:
11 C>
12 C> <pre>
13 C> PLN(0,0)=SQRT(0.5)
14 C> PLN(L,L)=PLN(L-1,L-1)*CLAT*SQRT(FLOAT(2*L+1)/FLOAT(2*L))
15 C> PLN(L,N)=(SLAT*PLN(L,N-1)-EPS(L,N-1)*PLN(L,N-2))/EPS(L,N)
16 C> </pre>
17 C>
18 C> Synthesis at the pole needs only two zonal wavenumbers. Scalar
19 C> fields are synthesized with zonal wavenumber 0 while vector
20 C> fields are synthesized with zonal wavenumber 1. (Thus polar
21 C> vector fields are implicitly divided by clat.) The following
22 C> bootstrapping formulas are used at the pole:
23 C>
24 C> <pre>
25 C> PLN(0,0)=SQRT(0.5)
26 C> PLN(1,1)=SQRT(0.75)
27 C> PLN(L,N)=(PLN(L,N-1)-EPS(L,N-1)*PLN(L,N-2))/EPS(L,N)
28 C> </pre>
29 C>
30 C> PROGRAM HISTORY LOG:
31 C> - 91-10-31 MARK IREDELL
32 C> - 98-06-10 MARK IREDELL GENERALIZE PRECISION
33 C>
34 C> @param I - INTEGER SPECTRAL DOMAIN SHAPE
35 C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
36 C> @param M - INTEGER SPECTRAL TRUNCATION
37 C> @param SLAT - REAL SINE OF LATITUDE
38 C> @param CLAT - REAL COSINE OF LATITUDE
39 C> @param EPS - REAL ((M+1)*((I+1)*M+2)/2) SQRT((N**2-L**2)/(4*N**2-1))
40 C> @param EPSTOP - REAL (M+1) SQRT((N**2-L**2)/(4*N**2-1)) OVER TOP
41 C> @param[out] PLN - REAL ((M+1)*((I+1)*M+2)/2) LEGENDRE POLYNOMIAL
42 C> @param[out] PLNTOP - REAL (M+1) LEGENDRE POLYNOMIAL OVER TOP
43 C>
44  SUBROUTINE splegend(I,M,SLAT,CLAT,EPS,EPSTOP,PLN,PLNTOP)
45 
46 CFPP$ 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
51 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
52 C 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
79 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
80 C 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
94 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
95 C 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
105 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106 C COMPUTE PLN(L,L+1) (DIAGONAL NEXT TO BOTTOM HYPOTENUSE OF DOMAIN)
107  nml=1
108 CDIR$ 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
113 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
114 C COMPUTE REMAINING PLN IN SPECTRAL DOMAIN
115  DO nml=2,m
116 CDIR$ 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
122 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
123 C 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
132 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
133 C 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