NCEPLIBS-sp  2.5.0
sptgpsd.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Transform spectral to polar stereographic gradients
3 C> ### Program history log:
4 C> Date | Programmer | Comments
5 C> -----|------------|----------
6 C> 96-02-29 | IREDELL | Initial.
7 C> 1998-12-15 | IREDELL | OpenMP directives inserted.
8 C> @author IREDELL @date 96-02-29
9 
10 C> This subprogram performs a spherical transform
11 C> from spectral coefficients of scalar fields
12 C> to gradient fields on a pair of polar stereographic grids.
13 C> The wave-space can be either triangular or rhomboidal.
14 C> The wave and grid fields may have general indexing,
15 C> but each wave field is in sequential 'ibm order',
16 C> i.e., with zonal wavenumber as the slower index.
17 C> The two square polar stereographic grids are centered
18 C> on the respective poles, with the orientation longitude
19 C> of the southern hemisphere grid 180 degrees opposite
20 C> that of the northern hemisphere grid.
21 C> The vectors are automatically rotated to be resolved
22 C> relative to the respective polar stereographic grids.
23 C>
24 C> The transform is made efficient by combining points in eight
25 C> sectors of each polar stereographic grid, numbered as in the
26 C> following diagram. The pole and the sector boundaries are
27 C> treated specially in the code. Unfortunately, this approach
28 C> induces some hairy indexing and code loquacity, for which
29 C> the developer apologizes.
30 C>
31 C> \verbatim
32 C> \ 4 | 5 /
33 C> \ | /
34 C> 3 \ | / 6
35 C> \|/
36 C> ----+----
37 C> /|\
38 C> 2 / | \ 7
39 C> / | \
40 C> / 1 | 8 \
41 C> \endverbatim
42 C>
43 C> The transforms are all multiprocessed over sector points.
44 C> transform several fields at a time to improve vectorization.
45 C> Subprogram can be called from a multiprocessing environment.
46 C>
47 C> @param IROMB Spectral domain shape
48 C> (0 for triangular, 1 for rhomboidal)
49 C> @param MAXWV Spectral truncation
50 C> @param KMAX Number of fields to transform
51 C> @param NPS Odd order of the polar stereographic grids
52 C> @param KWSKIP Skip number between wave fields
53 C> (defaults to (MAXWV+1)*((IROMB+1)*MAXWV+2) if KWSKIP=0)
54 C> @param KGSKIP Skip number between grid fields
55 C> (defaults to NPS*NPS if KGSKIP=0)
56 C> @param NISKIP Skip number between grid i-points
57 C> (defaults to 1 if NISKIP=0)
58 C> @param NJSKIP Skip number between grid j-points
59 C> (defaults to NPS if NJSKIP=0)
60 C> @param TRUE Latitude at which PS grid is true (usually 60.)
61 C> @param XMESH Grid length at true latitude (M)
62 C> @param ORIENT Longitude at bottom of northern PS grid
63 C> (southern PS grid will have opposite orientation.)
64 C> @param WAVE Wave fields
65 C> @param XN Northern polar stereographic x-gradients
66 C> @param YN Northern polar stereographic y-gradients
67 C> @param XS Southern polar stereographic x-gradients
68 C> @param YS Southern polar stereographic y-gradients
69 C>
70 C> @author IREDELL @date 96-02-29
71  SUBROUTINE sptgpsd(IROMB,MAXWV,KMAX,NPS,
72  & KWSKIP,KGSKIP,NISKIP,NJSKIP,
73  & TRUE,XMESH,ORIENT,WAVE,XN,YN,XS,YS)
74 
75  REAL WAVE(*),XN(*),YN(*),XS(*),YS(*)
76  REAL EPS((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EPSTOP(MAXWV+1)
77  REAL ENN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
78  REAL ELONN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
79  REAL EON((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EONTOP(MAXWV+1)
80  REAL WD((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
81  REAL WZ((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
82 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
83 C CALCULATE PRELIMINARY CONSTANTS
84  CALL spwget(iromb,maxwv,eps,epstop,enn1,elonn1,eon,eontop)
85  mx=(maxwv+1)*((iromb+1)*maxwv+2)/2
86  mdim=2*mx+1
87  kw=kwskip
88  IF(kw.EQ.0) kw=2*mx
89 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
90 C CALCULATE GRADIENTS
91 C$OMP PARALLEL DO PRIVATE(KWS)
92  DO k=1,kmax
93  kws=(k-1)*kw
94  CALL splaplac(iromb,maxwv,enn1,wave(kws+1),wd(1,k),1)
95  wz(1:2*mx,k)=0.
96  ENDDO
97  CALL sptgpsv(iromb,maxwv,kmax,nps,mdim,kgskip,niskip,njskip,
98  & true,xmesh,orient,wd,wz,xn,yn,xs,ys)
99 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
100  END
subroutine splaplac(I, M, ENN1, Q, QD2, IDIR)
Computes the laplacian or the inverse laplacian of a scalar field in spectral space.
Definition: splaplac.f:25
subroutine sptgpsd(IROMB, MAXWV, KMAX, NPS, KWSKIP, KGSKIP, NISKIP, NJSKIP, TRUE, XMESH, ORIENT, WAVE, XN, YN, XS, YS)
This subprogram performs a spherical transform from spectral coefficients of scalar fields to gradien...
Definition: sptgpsd.f:74
subroutine sptgpsv(IROMB, MAXWV, KMAX, NPS, KWSKIP, KGSKIP, NISKIP, NJSKIP, TRUE, XMESH, ORIENT, WAVED, WAVEZ, UN, VN, US, VS)
This subprogram performs a spherical transform from spectral coefficients of divergences and curls to...
Definition: sptgpsv.f:83
subroutine spwget(IROMB, MAXWV, EPS, EPSTOP, ENN1, ELONN1, EON, EONTOP)
This subprogram gets wave-space constants.
Definition: spwget.f:18