NCEPLIBS-ip  5.1.0
sptgpmv.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Transform spectral vector to Mercator
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 divergences and curls
12 C> to vector fields on a Mercator grid.
13 C>
14 C> The wave-space can be either triangular or rhomboidal.
15 C>
16 C> The wave and grid fields may have general indexing,
17 C> but each wave field is in sequential 'ibm order',
18 C> i.e., with zonal wavenumber as the slower index.
19 C>
20 C> The Mercator grid is identified by the location
21 C> of its first point and by its respective increments.
22 C>
23 C> The transforms are all multiprocessed over sector points.
24 C> Transform several fields at a time to improve vectorization.
25 C>
26 C> Subprogram can be called from a multiprocessing environment.
27 C>
28 C> @param IROMB Spectral domain shape
29 C> (0 for triangular, 1 for rhomboidal)
30 C> @param MAXWV Spectral truncation
31 C> @param KMAX Number of fields to transform
32 C> @param MI Number of points in the faster zonal direction
33 C> @param MJ Number of points in the slower merid direction
34 C> @param KWSKIP Skip number between wave fields
35 C> (defaults to (MAXWV+1)*((IROMB+1)*MAXWV+2) if KWSKIP=0)
36 C> @param KGSKIP Skip number between grid fields
37 C> (defaults to MI*MJ if KGSKIP=0)
38 C> @param NISKIP Skip number between grid i-points
39 C> (defaults to 1 if NISKIP=0)
40 C> @param NJSKIP Skip number between grid j-points
41 C> (defaults to MI if NJSKIP=0)
42 C> @param RLAT1 Latitude of the first grid point in degrees
43 C> @param RLON1 Longitude of the first grid point in degrees
44 C> @param DLAT Latitude increment in degrees such that
45 C> D(PHI)/D(J)=DLAT*COS(PHI) where J is meridional index.
46 C> DLAT is negative for grids indexed southward.
47 C> (in terms of grid increment dy valid at latitude RLATI,
48 C> The latitude increment DLAT is determined as
49 C> DLAT=DPR*DY/(RERTH*COS(RLATI/DPR))
50 C> where DPR=180/PI and RERTH is Earth's radius)
51 C> @param DLON longitude increment in degrees such that
52 C> D(LAMBDA)/D(I)=DLON where I is zonal index.
53 C> DLON is negative for grids indexed westward.
54 C> @param WAVED Wave divergence fields
55 C> @param WAVEZ Wave vorticity fields
56 C> @param UM Mercator u-winds
57 C> @param VM Mercator v-winds
58 C>
59 C> @author IREDELL @date 96-02-29
60  SUBROUTINE sptgpmv(IROMB,MAXWV,KMAX,MI,MJ,
61  & KWSKIP,KGSKIP,NISKIP,NJSKIP,
62  & RLAT1,RLON1,DLAT,DLON,WAVED,WAVEZ,UM,VM)
63 
64  REAL WAVED(*),WAVEZ(*),UM(*),VM(*)
65  REAL EPS((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EPSTOP(MAXWV+1)
66  REAL ENN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
67  REAL ELONN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
68  REAL EON((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EONTOP(MAXWV+1)
69  INTEGER MP(2*KMAX)
70  REAL W((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,2*KMAX)
71  REAL WTOP(2*(MAXWV+1),2*KMAX)
72  REAL PLN((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),PLNTOP(MAXWV+1)
73  REAL F(2*MAXWV+3,2,2*KMAX)
74  REAL CLAT(MJ),SLAT(MJ),CLON(MAXWV,MI),SLON(MAXWV,MI)
75  parameter(pi=3.14159265358979,dpr=180./pi)
76 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
77 C CALCULATE PRELIMINARY CONSTANTS
78  CALL spwget(iromb,maxwv,eps,epstop,enn1,elonn1,eon,eontop)
79  mx=(maxwv+1)*((iromb+1)*maxwv+2)/2
80  mxtop=maxwv+1
81  mdim=2*mx+1
82  idim=2*maxwv+3
83  kw=kwskip
84  kg=kgskip
85  ni=niskip
86  nj=njskip
87  IF(kw.EQ.0) kw=2*mx
88  IF(kg.EQ.0) kg=mi*mj
89  IF(ni.EQ.0) ni=1
90  IF(nj.EQ.0) nj=mi
91  DO i=1,mi
92  rlon=mod(rlon1+dlon*(i-1)+3600,360.)
93  DO l=1,maxwv
94  clon(l,i)=cos(l*rlon/dpr)
95  slon(l,i)=sin(l*rlon/dpr)
96  ENDDO
97  ENDDO
98  ye=1-log(tan((rlat1+90)/2/dpr))*dpr/dlat
99  DO j=1,mj
100  rlat=atan(exp(dlat/dpr*(j-ye)))*2*dpr-90
101  clat(j)=cos(rlat/dpr)
102  slat(j)=sin(rlat/dpr)
103  ENDDO
104  mp=1
105 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106 C CALCULATE SPECTRAL WINDS
107 C$OMP PARALLEL DO PRIVATE(KWS)
108  DO k=1,kmax
109  kws=(k-1)*kw
110  CALL spdz2uv(iromb,maxwv,enn1,elonn1,eon,eontop,
111  & waved(kws+1),wavez(kws+1),
112  & w(1,k),w(1,kmax+k),wtop(1,k),wtop(1,kmax+k))
113  ENDDO
114 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
115 C TRANSFORM TO GRID
116 C$OMP PARALLEL DO PRIVATE(PLN,PLNTOP,F,KU,KV,IJK)
117  DO j=1,mj
118  CALL splegend(iromb,maxwv,slat(j),clat(j),eps,epstop,
119  & pln,plntop)
120  CALL spsynth(iromb,maxwv,2*maxwv,idim,mdim,2*mxtop,2*kmax,
121  & clat(j),pln,plntop,mp,w,wtop,f)
122  DO k=1,kmax
123  ku=k
124  kv=k+kmax
125  DO i=1,mi
126  ijk=(i-1)*ni+(j-1)*nj+(k-1)*kg+1
127  um(ijk)=f(1,1,ku)
128  vm(ijk)=f(1,1,kv)
129  ENDDO
130  DO l=1,maxwv
131  DO i=1,mi
132  ijk=(i-1)*ni+(j-1)*nj+(k-1)*kg+1
133  um(ijk)=um(ijk)+2.*(f(2*l+1,1,ku)*clon(l,i)
134  & -f(2*l+2,1,ku)*slon(l,i))
135  vm(ijk)=vm(ijk)+2.*(f(2*l+1,1,kv)*clon(l,i)
136  & -f(2*l+2,1,kv)*slon(l,i))
137  ENDDO
138  ENDDO
139  ENDDO
140  ENDDO
141 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
142  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 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 sptgpmv(IROMB, MAXWV, KMAX, MI, MJ, KWSKIP, KGSKIP, NISKIP, NJSKIP, RLAT1, RLON1, DLAT, DLON, WAVED, WAVEZ, UM, VM)
This subprogram performs a spherical transform from spectral coefficients of divergences and curls to...
Definition: sptgpmv.f:63
subroutine spwget(IROMB, MAXWV, EPS, EPSTOP, ENN1, ELONN1, EON, EONTOP)
This subprogram gets wave-space constants.
Definition: spwget.f:18