NCEPLIBS-sp  2.5.0
sptgpm.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Transform spectral scalar 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 scalar quantities
12 C> to scalar fields on a Mercator grid.
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 Mercator grid is identified by the location
18 C> of its first point and by its respective increments.
19 C> The transforms are all multiprocessed over sector points.
20 C> Transform several fields at a time to improve vectorization.
21 C> Subprogram can be called from a multiprocessing environment.
22 C>
23 C> @param IROMB Spectral domain shape
24 C> (0 for triangular, 1 for rhomboidal)
25 C> @param MAXWV Spectral truncation
26 C> @param KMAX Number of fields to transform
27 C> @param MI Number of points in the faster zonal direction
28 C> @param MJ Number of points in the slower merid direction
29 C> @param KWSKIP Skip number between wave fields
30 C> (defaults to (MAXWV+1)*((IROMB+1)*MAXWV+2) if KWSKIP=0)
31 C> @param KGSKIP Skip number between grid fields
32 C> (defaults to MI*MJ if KGSKIP=0)
33 C> @param NISKIP Skip number between grid i-points
34 C> (defaults to 1 if NISKIP=0)
35 C> @param NJSKIP Skip number between grid j-points
36 C> (defaults to MI if NJSKIP=0)
37 C> @param RLAT1 Latitude of the first grid point in degrees
38 C> @param RLON1 Longitude of the first grid point in degrees
39 C> @param DLAT Latitude increment in degrees such that
40 C> D(PHI)/D(J)=DLAT*COS(PHI) where J is meridional index.
41 C> DLAT is negative for grids indexed southward.
42 C> (in terms of grid increment DY valid at latitude RLATI,
43 C> the latitude increment DLAT is determined as
44 C> DLAT=DPR*DY/(RERTH*COS(RLATI/DPR))
45 C> where DPR=180/PI and RERTH is earth's radius)
46 C> @param DLON Longitude increment in degrees such that
47 C> D(LAMBDA)/D(I)=DLON where I is zonal index.
48 C> DLON is negative for grids indexed westward.
49 C> @param WAVE Wave fields
50 C> @param GM Mercator fields
51 C>
52 C> @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)
69 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
70 C 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
97 C$OMP PARALLEL DO
98  DO k=1,kmax
99  wtop(1:2*mxtop,k)=0
100  ENDDO
101 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102 C TRANSFORM TO GRID
103 C$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
123 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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