NCEPLIBS-ip  5.1.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(pi=3.14159265358979,dpr=180./pi)
68 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
69 C 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
96 C$OMP PARALLEL DO
97  DO k=1,kmax
98  wtop(1:2*mxtop,k)=0
99  ENDDO
100 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
101 C TRANSFORM TO GRID
102 C$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
122 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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