NCEPLIBS-sp 2.4.0
sptrand.f
Go to the documentation of this file.
1C> @file
2C> @brief Perform a gradient spherical transform.
3C>
4C> ### Program History Log
5C> Date | Programmer | Comments
6C> -----|------------|---------
7C> 96-02-29 | IREDELL | Initial
8C> 1998-12-15 | IREDELL | openmp directives inserted
9C>
10C> @author Iredell @date 96-02-29
11
12C> This subprogram performs a spherical transform
13C> between spectral coefficients of scalar fields
14C> and their means and gradients on a global cylindrical grid.
15C>
16C> The wave-space can be either triangular or rhomboidal.
17C>
18C> The grid-space can be either an equally-spaced grid
19C> (with or without pole points) or a Gaussian grid.
20C>
21C> The wave and grid fields may have general indexing,
22C> but each wave field is in sequential 'IBM order',
23C> i.e. with zonal wavenumber as the slower index.
24C>
25C> Transforms are done in latitude pairs for efficiency;
26C> thus grid arrays for each hemisphere must be passed.
27C> if so requested, just a subset of the latitude pairs
28C> may be transformed in each invocation of the subprogram.
29C>
30C> The transforms are all multiprocessed over latitude except
31C> the transform from Fourier to spectral is multiprocessed
32C> over zonal wavenumber to ensure reproducibility.
33C>
34C> Transform several fields at a time to improve vectorization.
35C>
36C> Subprogram can be called from a multiprocessing environment.
37C>
38C> Minimum grid dimensions for unaliased transforms to spectral:
39C> DIMENSION |LINEAR |QUADRATIC
40C> ----------------------- |--------- |-------------
41C> IMAX |2*MAXWV+2 |3*MAXWV/2*2+2
42C> JMAX (IDRT=4,IROMB=0) |1*MAXWV+1 |3*MAXWV/2+1
43C> JMAX (IDRT=4,IROMB=1) |2*MAXWV+1 |5*MAXWV/2+1
44C> JMAX (IDRT=0,IROMB=0) |2*MAXWV+3 |3*MAXWV/2*2+3
45C> JMAX (IDRT=0,IROMB=1) |4*MAXWV+3 |5*MAXWV/2*2+3
46C> JMAX (IDRT=256,IROMB=0) |2*MAXWV+1 |3*MAXWV/2*2+1
47C> JMAX (IDRT=256,IROMB=1) |4*MAXWV+1 |5*MAXWV/2*2+1
48C>
49C> @param IROMB spectral domain shape
50C> (0 for triangular, 1 for rhomboidal)
51C> @param MAXWV spectral truncation
52C> @param IDRT grid identifier
53C> - IDRT=4 for Gaussian grid
54C> - IDRT=0 for equally-spaced grid including poles
55C> - IDRT=256 for equally-spaced grid excluding poles
56C> @param IMAX even number of longitudes.
57C> @param JMAX number of latitudes.
58C> @param KMAX number of fields to transform.
59C> @param IPRIME longitude index for the prime meridian.
60C> (defaults to 1 if IPRIME=0)
61C> @param ISKIP skip number between longitudes
62C> (defaults to 1 if ISKIP=0)
63C> @param JNSKIP skip number between n.h. latitudes from north
64C> (defaults to IMAX if JNSKIP=0)
65C> @param JSSKIP skip number between s.h. latitudes from south
66C> (defaults to -IMAX if JSSKIP=0)
67C> @param KWSKIP skip number between wave fields
68C> (defaults to (MAXWV+1)*((IROMB+1)*MAXWV+2) if KWSKIP=0)
69C> @param KGSKIP skip number between grid fields
70C> (defaults to IMAX*JMAX if KGSKIP=0)
71C> @param JBEG latitude index (from pole) to begin transform
72C> (defaults to 1 if JBEG=0). If JBEG=0 and IDIR<0, wave is zeroed before transform.
73C> @param JEND latitude index (from pole) to end transform
74C> (defaults to (JMAX+1)/2 if JEND=0)
75C> @param JCPU number of cpus over which to multiprocess
76C> @param[out] WAVE wave fields if IDIR>0
77C> @param[out] GRIDMN global means if IDIR<0
78C> @param[out] GRIDXN n.h. x-gradients (starting at JBEG) if IDIR<0
79C> @param[out] GRIDXS s.h. x-gradients (starting at JBEG) if IDIR<0
80C> [GRIDX=(D(WAVE)/DLAM)/(CLAT*RERTH)]
81C> @param[out] GRIDYN n.h. y-gradients (starting at JBEG) if IDIR<0
82C> @param[out] GRIDYS s.h. y-gradients (starting at JBEG) if IDIR<0
83C> [GRIDY=(D(WAVE)/DPHI)/RERTH]
84C> @param IDIR transform flag
85C> (IDIR>0 for wave to grid, IDIR<0 for grid to wave)
86C>
87C> @author Iredell @date 96-02-29
88 SUBROUTINE sptrand(IROMB,MAXWV,IDRT,IMAX,JMAX,KMAX,
89 & IPRIME,ISKIP,JNSKIP,JSSKIP,KWSKIP,KGSKIP,
90 & JBEG,JEND,JCPU,
91 & WAVE,GRIDMN,GRIDXN,GRIDXS,GRIDYN,GRIDYS,IDIR)
92
93 REAL WAVE(*),GRIDMN(KMAX),GRIDXN(*),GRIDXS(*),GRIDYN(*),GRIDYS(*)
94 REAL EPS((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EPSTOP(MAXWV+1)
95 REAL ENN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
96 REAL ELONN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
97 REAL EON((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EONTOP(MAXWV+1)
98 REAL WD((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
99 REAL WZ((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
100
101C SET PARAMETERS
102 CALL spwget(iromb,maxwv,eps,epstop,enn1,elonn1,eon,eontop)
103 mx=(maxwv+1)*((iromb+1)*maxwv+2)/2
104 mdim=2*mx+1
105 kw=kwskip
106 IF(kw.EQ.0) kw=2*mx
107
108C TRANSFORM WAVE TO GRID
109 IF(idir.GT.0) THEN
110C$OMP PARALLEL DO PRIVATE(KWS)
111 DO k=1,kmax
112 kws=(k-1)*kw
113 gridmn(k)=wave(kws+1)/sqrt(2.)
114 CALL splaplac(iromb,maxwv,enn1,wave(kws+1),wd(1,k),1)
115 wz(1:2*mx,k)=0.
116 ENDDO
117 CALL sptranv(iromb,maxwv,idrt,imax,jmax,kmax,
118 & iprime,iskip,jnskip,jsskip,mdim,kgskip,
119 & jbeg,jend,jcpu,
120 & wd,wz,gridxn,gridxs,gridyn,gridys,idir)
121
122C TRANSFORM GRID TO WAVE
123 ELSE
124C$OMP PARALLEL DO
125 DO k=1,kmax
126 wd(1:2*mx,k)=0.
127 wz(1:2*mx,k)=0.
128 ENDDO
129 CALL sptranv(iromb,maxwv,idrt,imax,jmax,kmax,
130 & iprime,iskip,jnskip,jsskip,mdim,kgskip,
131 & jbeg,jend,jcpu,
132 & wd,wz,gridxn,gridxs,gridyn,gridys,idir)
133 IF(jbeg.EQ.0) THEN
134C$OMP PARALLEL DO PRIVATE(KWS)
135 DO k=1,kmax
136 kws=(k-1)*kw
137 CALL splaplac(iromb,maxwv,enn1,wave(kws+1),wd(1,k),-1)
138 wave(kws+1)=gridmn(k)*sqrt(2.)
139 ENDDO
140 ELSE
141C$OMP PARALLEL DO PRIVATE(KWS)
142 DO k=1,kmax
143 kws=(k-1)*kw
144 CALL splaplac(iromb,maxwv,enn1,wz(1,k),wd(1,k),-1)
145 wave(kws+1:kws+2*mx)=wave(kws+1:kws+2*mx)+wz(1:2*mx,k)
146 wave(kws+1)=gridmn(k)*sqrt(2.)
147 ENDDO
148 ENDIF
149 ENDIF
150 END
subroutine splaplac(I, M, ENN1, Q, QD2, IDIR)
Computes the laplacian or the inverse laplacian of a scalar field in spectral space.
Definition: splaplac.f:25
subroutine sptrand(IROMB, MAXWV, IDRT, IMAX, JMAX, KMAX, IPRIME, ISKIP, JNSKIP, JSSKIP, KWSKIP, KGSKIP, JBEG, JEND, JCPU, WAVE, GRIDMN, GRIDXN, GRIDXS, GRIDYN, GRIDYS, IDIR)
This subprogram performs a spherical transform between spectral coefficients of scalar fields and the...
Definition: sptrand.f:92
subroutine sptranv(IROMB, MAXWV, IDRT, IMAX, JMAX, KMAX, IPRIME, ISKIP, JNSKIP, JSSKIP, KWSKIP, KGSKIP, JBEG, JEND, JCPU, WAVED, WAVEZ, GRIDUN, GRIDUS, GRIDVN, GRIDVS, IDIR)
This subprogram performs a spherical transform between spectral coefficients of divergences and curls...
Definition: sptranv.f:91
subroutine spwget(IROMB, MAXWV, EPS, EPSTOP, ENN1, ELONN1, EON, EONTOP)
This subprogram gets wave-space constants.
Definition: spwget.f:18