NCEPLIBS-sp  2.5.0
spgradq.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Compute gradient in spectral space.
3 C> @author Iredell @date 92-10-31
4 
5 C> Computes the horizontal vector gradient of a scalar field
6 C> in spectral space.
7 C>
8 C> Subprogram speps() should be called already.
9 C>
10 C> If l is the zonal wavenumber, n is the total wavenumber,
11 C> eps(l,n)=sqrt((n**2-l**2)/(4*n**2-1)) and a is earth radius,
12 C> then the zonal gradient of q(l,n) is simply i*l/a*q(l,n)
13 C> while the meridional gradient of q(l,n) is computed as
14 C> eps(l,n+1)*(n+2)/a*q(l,n+1)-eps(l,n+1)*(n-1)/a*q(l,n-1).
15 C>
16 C> Extra terms are computed over top of the spectral domain.
17 C>
18 C> Advantage is taken of the fact that eps(l,l)=0
19 C> in order to vectorize over the entire spectral domain.
20 C>
21 C> @param I spectral domain shape (0 for triangular, 1 for rhomboidal)
22 C> @param M spectral truncation
23 C> @param ENN1
24 C> @param ELONN1
25 C> @param EON EPSILON/N*A
26 C> @param EONTOP EPSILON/N*A over top
27 C> @param Q scalar field
28 C> @param QDX zonal gradient (times coslat)
29 C> @param QDY merid gradient (times coslat)
30 C> @param QDYTOP merid gradient (times coslat) over top
31 C>
32 C> @author IREDELL @date 92-10-31
33  SUBROUTINE spgradq(I,M,ENN1,ELONN1,EON,EONTOP,Q,QDX,QDY,QDYTOP)
34 
35  REAL ENN1((M+1)*((I+1)*M+2)/2),ELONN1((M+1)*((I+1)*M+2)/2)
36  REAL EON((M+1)*((I+1)*M+2)/2),EONTOP(M+1)
37  REAL Q((M+1)*((I+1)*M+2))
38  REAL QDX((M+1)*((I+1)*M+2)),QDY((M+1)*((I+1)*M+2))
39  REAL QDYTOP(2*(M+1))
40 
41 C TAKE ZONAL AND MERIDIONAL GRADIENTS
42  k=1
43  qdx(2*k-1)=0.
44  qdx(2*k)=0.
45  qdy(2*k-1)=eon(k+1)*enn1(k+1)*q(2*k+1)
46  qdy(2*k)=eon(k+1)*enn1(k+1)*q(2*k+2)
47  DO k=2,(m+1)*((i+1)*m+2)/2-1
48  qdx(2*k-1)=-elonn1(k)*enn1(k)*q(2*k)
49  qdx(2*k)=elonn1(k)*enn1(k)*q(2*k-1)
50  qdy(2*k-1)=eon(k+1)*enn1(k+1)*q(2*k+1)-eon(k)*enn1(k-1)*q(2*k-3)
51  qdy(2*k)=eon(k+1)*enn1(k+1)*q(2*k+2)-eon(k)*enn1(k-1)*q(2*k-2)
52  ENDDO
53  k=(m+1)*((i+1)*m+2)/2
54  qdx(2*k-1)=-elonn1(k)*enn1(k)*q(2*k)
55  qdx(2*k)=elonn1(k)*enn1(k)*q(2*k-1)
56  qdy(2*k-1)=-eon(k)*enn1(k-1)*q(2*k-3)
57  qdy(2*k)=-eon(k)*enn1(k-1)*q(2*k-2)
58 
59 C TAKE MERIDIONAL GRADIENT OVER TOP
60  DO l=0,m
61  k=l*(2*m+(i-1)*(l-1))/2+i*l+m+1
62  qdytop(2*l+1)=-eontop(l+1)*enn1(k)*q(2*k-1)
63  qdytop(2*l+2)=-eontop(l+1)*enn1(k)*q(2*k)
64  ENDDO
65  RETURN
66  END
subroutine spgradq(I, M, ENN1, ELONN1, EON, EONTOP, Q, QDX, QDY, QDYTOP)
Computes the horizontal vector gradient of a scalar field in spectral space.
Definition: spgradq.f:34