NCEPLIBS-sp  2.3.3
sptgpmv.f
Go to the documentation of this file.
1 C> @file
2 C>
3 C> Transform spectral vector to mercator
4 C> @author IREDELL @date 96-02-29
5 
6 C> THIS SUBPROGRAM PERFORMS A SPHERICAL TRANSFORM
7 C> FROM SPECTRAL COEFFICIENTS OF DIVERGENCES AND CURLS
8 C> TO VECTOR FIELDS ON A MERCATOR GRID.
9 C> THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
10 C> THE WAVE AND GRID FIELDS MAY HAVE GENERAL INDEXING,
11 C> BUT EACH WAVE FIELD IS IN SEQUENTIAL 'IBM ORDER',
12 C> I.E. WITH ZONAL WAVENUMBER AS THE SLOWER INDEX.
13 C> THE MERCATOR GRID IS IDENTIFIED BY THE LOCATION
14 C> OF ITS FIRST POINT AND BY ITS RESPECTIVE INCREMENTS.
15 C> THE TRANSFORMS ARE ALL MULTIPROCESSED OVER SECTOR POINTS.
16 C> TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
17 C> SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
18 C>
19 C> PROGRAM HISTORY LOG:
20 C> - 96-02-29 IREDELL
21 C> - 1998-12-15 IREDELL OPENMP DIRECTIVES INSERTED
22 C>
23 C> @param IROMB - INTEGER SPECTRAL DOMAIN SHAPE
24 C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
25 C> @param MAXWV - INTEGER SPECTRAL TRUNCATION
26 C> @param KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
27 C> @param MI - INTEGER NUMBER OF POINTS IN THE FASTER ZONAL DIRECTION
28 C> @param MJ - INTEGER NUMBER OF POINTS IN THE SLOWER MERID DIRECTION
29 C> @param KWSKIP - INTEGER SKIP NUMBER BETWEEN WAVE FIELDS
30 C> (DEFAULTS TO (MAXWV+1)*((IROMB+1)*MAXWV+2) IF KWSKIP=0)
31 C> @param KGSKIP - INTEGER SKIP NUMBER BETWEEN GRID FIELDS
32 C> (DEFAULTS TO MI*MJ IF KGSKIP=0)
33 C> @param NISKIP - INTEGER SKIP NUMBER BETWEEN GRID I-POINTS
34 C> (DEFAULTS TO 1 IF NISKIP=0)
35 C> @param NJSKIP - INTEGER SKIP NUMBER BETWEEN GRID J-POINTS
36 C> (DEFAULTS TO MI IF NJSKIP=0)
37 C> @param RLAT1 - REAL LATITUDE OF THE FIRST GRID POINT IN DEGREES
38 C> @param RLON1 - REAL LONGITUDE OF THE FIRST GRID POINT IN DEGREES
39 C> @param DLAT - REAL 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 - REAL 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 WAVED - REAL (*) WAVE DIVERGENCE FIELDS
50 C> @param WAVEZ - REAL (*) WAVE VORTICITY FIELDS
51 C> @param UM - REAL (*) MERCATOR U-WINDS
52 C> @param VM - REAL (*) MERCATOR V-WINDS
53 C>
54 C> SUBPROGRAMS CALLED:
55 C> - SPWGET() GET WAVE-SPACE CONSTANTS
56 C> - SPLEGEND() COMPUTE LEGENDRE POLYNOMIALS
57 C> - SPSYNTH() SYNTHESIZE FOURIER FROM SPECTRAL
58 C> - SPDZ2UV() COMPUTE WINDS FROM DIVERGENCE AND VORTICITY
59  SUBROUTINE sptgpmv(IROMB,MAXWV,KMAX,MI,MJ,
60  & KWSKIP,KGSKIP,NISKIP,NJSKIP,
61  & RLAT1,RLON1,DLAT,DLON,WAVED,WAVEZ,UM,VM)
62 
63  REAL WAVED(*),WAVEZ(*),UM(*),VM(*)
64  REAL EPS((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EPSTOP(MAXWV+1)
65  REAL ENN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
66  REAL ELONN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
67  REAL EON((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EONTOP(MAXWV+1)
68  INTEGER MP(2*KMAX)
69  REAL W((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,2*KMAX)
70  REAL WTOP(2*(MAXWV+1),2*KMAX)
71  REAL PLN((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),PLNTOP(MAXWV+1)
72  REAL F(2*MAXWV+3,2,2*KMAX)
73  REAL CLAT(MJ),SLAT(MJ),CLON(MAXWV,MI),SLON(MAXWV,MI)
74  parameter(rerth=6.3712e6)
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
spwget
subroutine spwget(IROMB, MAXWV, EPS, EPSTOP, ENN1, ELONN1, EON, EONTOP)
This subprogram gets wave-space constants.
Definition: spwget.f:22
splegend
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
spsynth
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:35
sptgpmv
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:62
spdz2uv
subroutine spdz2uv(I, M, ENN1, ELONN1, EON, EONTOP, D, Z, U, V, UTOP, VTOP)
Compute winds from divergence and vorticity.
Definition: spdz2uv.f:45