NCEPLIBS-sp 2.4.0
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(rerth=6.3712e6)
68 parameter(pi=3.14159265358979,dpr=180./pi)
69C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
70C CALCULATE PRELIMINARY CONSTANTS
71 CALL spwget(iromb,maxwv,eps,epstop,enn1,elonn1,eon,eontop)
72 mx=(maxwv+1)*((iromb+1)*maxwv+2)/2
73 mxtop=maxwv+1
74 idim=2*maxwv+3
75 kw=kwskip
76 kg=kgskip
77 ni=niskip
78 nj=njskip
79 IF(kw.EQ.0) kw=2*mx
80 IF(kg.EQ.0) kg=mi*mj
81 IF(ni.EQ.0) ni=1
82 IF(nj.EQ.0) nj=mi
83 DO i=1,mi
84 rlon=mod(rlon1+dlon*(i-1)+3600,360.)
85 DO l=1,maxwv
86 clon(l,i)=cos(l*rlon/dpr)
87 slon(l,i)=sin(l*rlon/dpr)
88 ENDDO
89 ENDDO
90 ye=1-log(tan((rlat1+90)/2/dpr))*dpr/dlat
91 DO j=1,mj
92 rlat=atan(exp(dlat/dpr*(j-ye)))*2*dpr-90
93 clat(j)=cos(rlat/dpr)
94 slat(j)=sin(rlat/dpr)
95 ENDDO
96 mp=0
97C$OMP PARALLEL DO
98 DO k=1,kmax
99 wtop(1:2*mxtop,k)=0
100 ENDDO
101C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102C TRANSFORM TO GRID
103C$OMP PARALLEL DO PRIVATE(PLN,PLNTOP,F,IJK)
104 DO j=1,mj
105 CALL splegend(iromb,maxwv,slat(j),clat(j),eps,epstop,
106 & pln,plntop)
107 CALL spsynth(iromb,maxwv,2*maxwv,idim,kw,2*mxtop,kmax,
108 & clat(j),pln,plntop,mp,wave,wtop,f)
109 DO k=1,kmax
110 DO i=1,mi
111 ijk=(i-1)*ni+(j-1)*nj+(k-1)*kg+1
112 gm(ijk)=f(1,1,k)
113 ENDDO
114 DO l=1,maxwv
115 DO i=1,mi
116 ijk=(i-1)*ni+(j-1)*nj+(k-1)*kg+1
117 gm(ijk)=gm(ijk)+2.*(f(2*l+1,1,k)*clon(l,i)
118 & -f(2*l+2,1,k)*slon(l,i))
119 ENDDO
120 ENDDO
121 ENDDO
122 ENDDO
123C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
124 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