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