NCEPLIBS-sp  2.3.3
spsynth.f
Go to the documentation of this file.
1 C> @file
2 C>
3 C> Synthesize fourier from spectral
4 C> @author IREDELL @date 92-10-31
5 
6 C> SYNTHESIZES FOURIER COEFFICIENTS FROM SPECTRAL COEFFICIENTS
7 C> FOR A LATITUDE PAIR (NORTHERN AND SOUTHERN HEMISPHERES).
8 C> VECTOR COMPONENTS ARE DIVIDED BY COSINE OF LATITUDE.
9 C>
10 C> PROGRAM HISTORY LOG:
11 C> - 91-10-31 MARK IREDELL
12 C> - 1998-12-18 MARK IREDELL INCLUDE SCALAR AND GRADIENT OPTION
13 C>
14 C> @param I - INTEGER SPECTRAL DOMAIN SHAPE
15 C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
16 C> @param M - INTEGER SPECTRAL TRUNCATION
17 C> @param IM - INTEGER EVEN NUMBER OF FOURIER COEFFICIENTS
18 C> @param IX - INTEGER DIMENSION OF FOURIER COEFFICIENTS (IX>=IM+2)
19 C> @param NC - INTEGER DIMENSION OF SPECTRAL COEFFICIENTS
20 C> (NC>=(M+1)*((I+1)*M+2))
21 C> @param NCTOP - INTEGER DIMENSION OF SPECTRAL COEFFICIENTS OVER TOP
22 C> (NCTOP>=2*(M+1))
23 C> @param KM - INTEGER NUMBER OF FIELDS
24 C> @param CLAT - REAL COSINE OF LATITUDE
25 C> @param PLN - REAL ((M+1)*((I+1)*M+2)/2) LEGENDRE POLYNOMIAL
26 C> @param PLNTOP - REAL (M+1) LEGENDRE POLYNOMIAL OVER TOP
27 C> @param SPC - REAL (NC,KM) SPECTRAL COEFFICIENTS
28 C> @param SPCTOP - REAL (NCTOP,KM) SPECTRAL COEFFICIENTS OVER TOP
29 C> @param MP - INTEGER (KM) IDENTIFIERS (0 FOR SCALAR, 1 FOR VECTOR,
30 C> OR 10 FOR SCALAR AND GRADIENT)
31 C>
32 C> @param F - REAL (IX,2,KM) FOURIER COEFFICIENTS FOR LATITUDE PAIR
33  SUBROUTINE spsynth(I,M,IM,IX,NC,NCTOP,KM,CLAT,PLN,PLNTOP,MP,
34  & SPC,SPCTOP,F)
35 
36  REAL PLN((M+1)*((I+1)*M+2)/2),PLNTOP(M+1)
37  INTEGER MP(KM)
38  REAL SPC(NC,KM),SPCTOP(NCTOP,KM)
39  REAL F(IX,2,KM)
40 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41 C ZERO OUT FOURIER COEFFICIENTS.
42  DO k=1,km
43  DO l=0,im/2
44  f(2*l+1,1,k)=0.
45  f(2*l+2,1,k)=0.
46  f(2*l+1,2,k)=0.
47  f(2*l+2,2,k)=0.
48  ENDDO
49  ENDDO
50 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
51 C SYNTHESIS OVER POLE.
52 C INITIALIZE FOURIER COEFFICIENTS WITH TERMS OVER TOP OF THE SPECTRUM.
53 C INITIALIZE EVEN AND ODD POLYNOMIALS SEPARATELY.
54  IF(clat.EQ.0) THEN
55  ltope=mod(m+1+i,2)
56 !C$OMP PARALLEL DO PRIVATE(LB,LE,L,KS,KP,N,F1R,F1I)
57  DO k=1,km
58  lb=mp(k)
59  le=mp(k)
60  IF(mp(k).EQ.10) THEN
61  lb=0
62  le=1
63  ENDIF
64  l=lb
65  IF(l.EQ.1) THEN
66  IF(l.EQ.ltope) THEN
67  f(2*l+1,1,k)=plntop(l+1)*spctop(2*l+1,k)
68  f(2*l+2,1,k)=plntop(l+1)*spctop(2*l+2,k)
69  ELSE
70  f(2*l+1,2,k)=plntop(l+1)*spctop(2*l+1,k)
71  f(2*l+2,2,k)=plntop(l+1)*spctop(2*l+2,k)
72  ENDIF
73  ENDIF
74 C FOR EACH ZONAL WAVENUMBER, SYNTHESIZE TERMS OVER TOTAL WAVENUMBER.
75 C SYNTHESIZE EVEN AND ODD POLYNOMIALS SEPARATELY.
76  DO l=lb,le
77  ks=l*(2*m+(i-1)*(l-1))
78  kp=ks/2+1
79  DO n=l,i*l+m,2
80  f(2*l+1,1,k)=f(2*l+1,1,k)+pln(kp+n)*spc(ks+2*n+1,k)
81  f(2*l+2,1,k)=f(2*l+2,1,k)+pln(kp+n)*spc(ks+2*n+2,k)
82  ENDDO
83  DO n=l+1,i*l+m,2
84  f(2*l+1,2,k)=f(2*l+1,2,k)+pln(kp+n)*spc(ks+2*n+1,k)
85  f(2*l+2,2,k)=f(2*l+2,2,k)+pln(kp+n)*spc(ks+2*n+2,k)
86  ENDDO
87 C SEPARATE FOURIER COEFFICIENTS FROM EACH HEMISPHERE.
88 C ODD POLYNOMIALS CONTRIBUTE NEGATIVELY TO THE SOUTHERN HEMISPHERE.
89  f1r=f(2*l+1,1,k)
90  f1i=f(2*l+2,1,k)
91  f(2*l+1,1,k)=f1r+f(2*l+1,2,k)
92  f(2*l+2,1,k)=f1i+f(2*l+2,2,k)
93  f(2*l+1,2,k)=f1r-f(2*l+1,2,k)
94  f(2*l+2,2,k)=f1i-f(2*l+2,2,k)
95  ENDDO
96  ENDDO
97 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98 C SYNTHESIS OVER FINITE LATITUDE.
99 C INITIALIZE FOURIER COEFFICIENTS WITH TERMS OVER TOP OF THE SPECTRUM.
100 C INITIALIZE EVEN AND ODD POLYNOMIALS SEPARATELY.
101  ELSE
102  lx=min(m,im/2)
103  ltope=mod(m+1,2)
104  ltopo=1-ltope
105  le=1+i*ltope
106  lo=2-i*ltopo
107 !C$OMP PARALLEL DO PRIVATE(L,KS,KP,N,F1R,F1I)
108  DO k=1,km
109  IF(mp(k).EQ.1) THEN
110  DO l=ltope,lx,2
111  f(2*l+1,le,k)=plntop(l+1)*spctop(2*l+1,k)
112  f(2*l+2,le,k)=plntop(l+1)*spctop(2*l+2,k)
113  ENDDO
114  DO l=ltopo,lx,2
115  f(2*l+1,lo,k)=plntop(l+1)*spctop(2*l+1,k)
116  f(2*l+2,lo,k)=plntop(l+1)*spctop(2*l+2,k)
117  ENDDO
118  ENDIF
119 C FOR EACH ZONAL WAVENUMBER, SYNTHESIZE TERMS OVER TOTAL WAVENUMBER.
120 C SYNTHESIZE EVEN AND ODD POLYNOMIALS SEPARATELY.
121  DO l=0,lx
122  ks=l*(2*m+(i-1)*(l-1))
123  kp=ks/2+1
124  DO n=l,i*l+m,2
125  f(2*l+1,1,k)=f(2*l+1,1,k)+pln(kp+n)*spc(ks+2*n+1,k)
126  f(2*l+2,1,k)=f(2*l+2,1,k)+pln(kp+n)*spc(ks+2*n+2,k)
127  ENDDO
128  DO n=l+1,i*l+m,2
129  f(2*l+1,2,k)=f(2*l+1,2,k)+pln(kp+n)*spc(ks+2*n+1,k)
130  f(2*l+2,2,k)=f(2*l+2,2,k)+pln(kp+n)*spc(ks+2*n+2,k)
131  ENDDO
132  ENDDO
133 C SEPARATE FOURIER COEFFICIENTS FROM EACH HEMISPHERE.
134 C ODD POLYNOMIALS CONTRIBUTE NEGATIVELY TO THE SOUTHERN HEMISPHERE.
135 C DIVIDE VECTOR COMPONENTS BY COSINE LATITUDE.
136  DO l=0,lx
137  f1r=f(2*l+1,1,k)
138  f1i=f(2*l+2,1,k)
139  f(2*l+1,1,k)=f1r+f(2*l+1,2,k)
140  f(2*l+2,1,k)=f1i+f(2*l+2,2,k)
141  f(2*l+1,2,k)=f1r-f(2*l+1,2,k)
142  f(2*l+2,2,k)=f1i-f(2*l+2,2,k)
143  ENDDO
144  IF(mp(k).EQ.1) THEN
145  DO l=0,lx
146  f(2*l+1,1,k)=f(2*l+1,1,k)/clat
147  f(2*l+2,1,k)=f(2*l+2,1,k)/clat
148  f(2*l+1,2,k)=f(2*l+1,2,k)/clat
149  f(2*l+2,2,k)=f(2*l+2,2,k)/clat
150  ENDDO
151  ENDIF
152  ENDDO
153  ENDIF
154 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
155  END
spsynth
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:35