NCEPLIBS-sp  2.5.0
sptgptvd.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Transform spectral vector to station points.
3 C>
4 C> ### Program History Log
5 C> Date | Programmer | Comments
6 C> -----|------------|---------
7 C> 96-02-29 | Iredell | Initial.
8 C> 1998-12-15 | Iredell | Openmp directives inserted.
9 C> 1999-08-18 | Iredell | Openmp directive typo fixed.
10 C>
11 C> @author Iredell @date 96-02-29
12 
13 C> This subprogram performs a spherical transform
14 C> from spectral coefficients of divergences and curls
15 C> to specified sets of station point vectors and their
16 C> gradients on the globe.
17 C>
18 C> <pre>
19 C> DP=(D(UP)/DLON+D(VP*CLAT)/DLAT)/(R*CLAT)
20 C> ZP=(D(VP)/DLON-D(UP*CLAT)/DLAT)/(R*CLAT)
21 C> UXP=D(UP*CLAT)/DLON/(R*CLAT)
22 C> VXP=D(VP*CLAT)/DLON/(R*CLAT)
23 C> UYP=D(UP*CLAT)/DLAT/R
24 C> VYP=D(VP*CLAT)/DLAT/R
25 C> </pre>
26 C>
27 C> The wave-space can be either triangular or rhomboidal.
28 C>
29 C> The wave and point fields may have general indexing,
30 C> but each wave field is in sequential 'IBM order',
31 C> i.e. with zonal wavenumber as the slower index.
32 C>
33 C> The transforms are all multiprocessed over stations.
34 C>
35 C> Transform several fields at a time to improve vectorization.
36 C>
37 C> Subprogram can be called from a multiprocessing environment.
38 C>
39 C> @param IROMB spectral domain shape
40 C> (0 for triangular, 1 for rhomboidal)
41 C> @param MAXWV spectral truncation
42 C> @param KMAX number of fields to transform.
43 C> @param NMAX number of station points to return
44 C> @param KWSKIP skip number between wave fields
45 C> (defaults to (MAXWV+1)*((IROMB+1)*MAXWV+2) IF KWSKIP=0)
46 C> @param KGSKIP skip number between station point sets
47 C> (defaults to NMAX if KGSKIP=0)
48 C> @param NRSKIP skip number between station lats and lons
49 C> (defaults to 1 if NRSKIP=0)
50 C> @param NGSKIP skip number between station points
51 C> (defaults to 1 if NGSKIP=0)
52 C> @param RLAT station latitudes in degrees
53 C> @param RLON station longitudes in degrees
54 C> @param WAVED wave divergence fields
55 C> @param WAVEZ wave vorticity fields
56 C> @param DP station point divergence sets
57 C> @param ZP station point vorticity sets
58 C> @param UP station point u-wind sets
59 C> @param VP station point v-wind sets
60 C> @param UXP station point u-wind x-gradient sets
61 C> @param VXP station point v-wind x-gradient sets
62 C> @param UYP station point u-wind y-gradient sets
63 C> @param VYP station point v-wind y-gradient sets
64 C>
65 C> @author Iredell @date 96-02-29
66  SUBROUTINE sptgptvd(IROMB,MAXWV,KMAX,NMAX,
67  & KWSKIP,KGSKIP,NRSKIP,NGSKIP,
68  & RLAT,RLON,WAVED,WAVEZ,
69  & DP,ZP,UP,VP,UXP,VXP,UYP,VYP)
70 
71  REAL RLAT(*),RLON(*),WAVED(*),WAVEZ(*)
72  REAL DP(*),ZP(*),UP(*),VP(*),UXP(*),VXP(*),UYP(*),VYP(*)
73  REAL EPS((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EPSTOP(MAXWV+1)
74  REAL ENN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
75  REAL ELONN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
76  REAL EON((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EONTOP(MAXWV+1)
77  INTEGER MP(4*KMAX)
78  REAL W((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2,4*KMAX)
79  REAL WTOP(2*(MAXWV+1),4*KMAX)
80  REAL PLN((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),PLNTOP(MAXWV+1)
81  REAL F(2*MAXWV+2,2,6*KMAX),G(6*KMAX)
82  parameter(pi=3.14159265358979)
83 
84 C CALCULATE PRELIMINARY CONSTANTS
85  CALL spwget(iromb,maxwv,eps,epstop,enn1,elonn1,eon,eontop)
86  mx=(maxwv+1)*((iromb+1)*maxwv+2)/2
87  mxtop=maxwv+1
88  mdim=2*mx
89  idim=2*maxwv+2
90  kw=kwskip
91  kg=kgskip
92  nr=nrskip
93  ng=ngskip
94  IF(kw.EQ.0) kw=2*mx
95  IF(kg.EQ.0) kg=nmax
96  IF(nr.EQ.0) nr=1
97  IF(ng.EQ.0) ng=1
98  mp(1:2*kmax)=0
99  mp(2*kmax+1:4*kmax)=1
100 
101 C CALCULATE SPECTRAL WINDS
102 C$OMP PARALLEL DO PRIVATE(KWS,KD,KZ,KU,KV)
103  DO k=1,kmax
104  kws=(k-1)*kw
105  kd=0*kmax+k
106  kz=1*kmax+k
107  ku=2*kmax+k
108  kv=3*kmax+k
109  DO i=1,2*mx
110  w(i,kd)=waved(kws+i)
111  w(i,kz)=wavez(kws+i)
112  ENDDO
113  DO i=1,2*mxtop
114  wtop(i,kd)=0
115  wtop(i,kz)=0
116  ENDDO
117  CALL spdz2uv(iromb,maxwv,enn1,elonn1,eon,eontop,
118  & waved(kws+1),wavez(kws+1),
119  & w(1,ku),w(1,kv),wtop(1,ku),wtop(1,kv))
120  ENDDO
121 
122 C CALCULATE STATION FIELDS
123 C$OMP PARALLEL DO PRIVATE(KD,KZ,KU,KV,KUX,KVX,SLAT1,CLAT1)
124 C$OMP& PRIVATE(PLN,PLNTOP,F,G,NK)
125  DO n=1,nmax
126  ku=2*kmax+1
127  kux=4*kmax+1
128  IF(abs(rlat((n-1)*nr+1)).GE.89.9995) THEN
129  slat1=sign(1.,rlat((n-1)*nr+1))
130  clat1=0.
131  ELSE
132  slat1=sin(pi/180*rlat((n-1)*nr+1))
133  clat1=cos(pi/180*rlat((n-1)*nr+1))
134  ENDIF
135  CALL splegend(iromb,maxwv,slat1,clat1,eps,epstop,
136  & pln,plntop)
137  CALL spsynth(iromb,maxwv,2*maxwv,idim,mdim,2*mxtop,4*kmax,
138  & clat1,pln,plntop,mp,w,wtop,f)
139  CALL spgradx(maxwv,idim,2*kmax,mp(2*kmax+1),clat1,
140  & f(1,1,2*kmax+1),f(1,1,4*kmax+1))
141  CALL spfftpt(maxwv,1,idim,1,6*kmax,rlon((n-1)*nr+1),f,g)
142  DO k=1,kmax
143  kd=0*kmax+k
144  kz=1*kmax+k
145  ku=2*kmax+k
146  kv=3*kmax+k
147  kux=4*kmax+k
148  kvx=5*kmax+k
149  nk=(n-1)*ng+(k-1)*kg+1
150  dp(nk)=g(kd)
151  zp(nk)=g(kz)
152  up(nk)=g(ku)
153  vp(nk)=g(kv)
154  uxp(nk)=g(kux)
155  vxp(nk)=g(kvx)
156  uyp(nk)=g(kvx)-clat1*g(kz)
157  vyp(nk)=clat1*g(kd)-g(kux)
158  ENDDO
159  ENDDO
160  END
subroutine spdz2uv(I, M, ENN1, ELONN1, EON, EONTOP, D, Z, U, V, UTOP, VTOP)
Computes the wind components from divergence and vorticity in spectral space.
Definition: spdz2uv.f:49
subroutine spfftpt(M, N, INCW, INCG, KMAX, RLON, W, G)
This subprogram computes a slow Fourier transform from Fourier space to a set of gridpoints.
Definition: spfftpt.f:23
subroutine spgradx(M, INCW, KMAX, MP, CLAT, W, WX)
This subprogram computes the x-gradient of fields in complex Fourier space.
Definition: spgradx.f:38
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
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:39
subroutine sptgptvd(IROMB, MAXWV, KMAX, NMAX, KWSKIP, KGSKIP, NRSKIP, NGSKIP, RLAT, RLON, WAVED, WAVEZ, DP, ZP, UP, VP, UXP, VXP, UYP, VYP)
This subprogram performs a spherical transform from spectral coefficients of divergences and curls to...
Definition: sptgptvd.f:70
subroutine spwget(IROMB, MAXWV, EPS, EPSTOP, ENN1, ELONN1, EON, EONTOP)
This subprogram gets wave-space constants.
Definition: spwget.f:18