NCEPLIBS-sp 2.4.0
spgradq.f
Go to the documentation of this file.
1C> @file
2C> @brief Compute gradient in spectral space.
3C> @author Iredell @date 92-10-31
4
5C> Computes the horizontal vector gradient of a scalar field
6C> in spectral space.
7C>
8C> Subprogram speps() should be called already.
9C>
10C> If l is the zonal wavenumber, n is the total wavenumber,
11C> eps(l,n)=sqrt((n**2-l**2)/(4*n**2-1)) and a is earth radius,
12C> then the zonal gradient of q(l,n) is simply i*l/a*q(l,n)
13C> while the meridional gradient of q(l,n) is computed as
14C> eps(l,n+1)*(n+2)/a*q(l,n+1)-eps(l,n+1)*(n-1)/a*q(l,n-1).
15C>
16C> Extra terms are computed over top of the spectral domain.
17C>
18C> Advantage is taken of the fact that eps(l,l)=0
19C> in order to vectorize over the entire spectral domain.
20C>
21C> @param I spectral domain shape (0 for triangular, 1 for rhomboidal)
22C> @param M spectral truncation
23C> @param ENN1
24C> @param ELONN1
25C> @param EON EPSILON/N*A
26C> @param EONTOP EPSILON/N*A over top
27C> @param Q scalar field
28C> @param QDX zonal gradient (times coslat)
29C> @param QDY merid gradient (times coslat)
30C> @param QDYTOP merid gradient (times coslat) over top
31C>
32C> @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
41C 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
59C 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