NCEPLIBS-sp 2.4.0
sptranv.f
Go to the documentation of this file.
1C> @file
2C> @brief Perform a vector spherical transform.
3C>
4C> ### Program History Log
5C> Date | Programmer | Comments
6C> -----|------------|---------
7C> 96-02-29 | IREDELL | Initial.
8C> 1998-12-15 | IREDELL | Generic fft used, openmp directives inserted
9C>
10C> @author IREDELL @date 96-02-29
11
12C> This subprogram performs a spherical transform
13C> between spectral coefficients of divergences and curls
14C> and vector fields 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> the wave and grid fields may have general indexing,
21C> but each wave field is in sequential 'ibm order',
22C> i.e. with zonal wavenumber as the slower index.
23C>
24C> Transforms are done in latitude pairs for efficiency;
25C> thus grid arrays for each hemisphere must be passed.
26C> If so requested, just a subset of the latitude pairs
27C> may be transformed in each invocation of the subprogram.
28C>
29C> The transforms are all multiprocessed over latitude except
30C> the transform from fourier to spectral is multiprocessed
31C> over zonal wavenumber to ensure reproducibility.
32C>
33C> Transform several fields at a time to improve vectorization.
34C> Subprogram can be called from a multiprocessing environment.
35C>
36C> Minimum grid dimensions for unaliased transforms to spectral:
37C> DIMENSION |LINEAR |QUADRATIC
38C> ----------------------- |--------- |-------------
39C> IMAX |2*MAXWV+2 |3*MAXWV/2*2+2
40C> JMAX (IDRT=4,IROMB=0) |1*MAXWV+1 |3*MAXWV/2+1
41C> JMAX (IDRT=4,IROMB=1) |2*MAXWV+1 |5*MAXWV/2+1
42C> JMAX (IDRT=0,IROMB=0) |2*MAXWV+3 |3*MAXWV/2*2+3
43C> JMAX (IDRT=0,IROMB=1) |4*MAXWV+3 |5*MAXWV/2*2+3
44C> JMAX (IDRT=256,IROMB=0) |2*MAXWV+1 |3*MAXWV/2*2+1
45C> JMAX (IDRT=256,IROMB=1) |4*MAXWV+1 |5*MAXWV/2*2+1
46C>
47C> @param IROMB SPECTRAL DOMAIN SHAPE
48C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
49C> @param MAXWV SPECTRAL TRUNCATION
50C> @param IDRT GRID IDENTIFIER
51C> - IDRT=4 FOR GAUSSIAN GRID,
52C> - IDRT=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
53C> - IDRT=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES
54C> @param IMAX EVEN NUMBER OF LONGITUDES.
55C> @param JMAX NUMBER OF LATITUDES.
56C> @param KMAX NUMBER OF FIELDS TO TRANSFORM.
57C> @param IPRIME LONGITUDE INDEX FOR THE PRIME MERIDIAN.
58C> (DEFAULTS TO 1 IF IPRIME=0)
59C> @param ISKIP SKIP NUMBER BETWEEN LONGITUDES
60C> (DEFAULTS TO 1 IF ISKIP=0)
61C> @param JNSKIP SKIP NUMBER BETWEEN N.H. LATITUDES FROM NORTH
62C> (DEFAULTS TO IMAX IF JNSKIP=0)
63C> @param JSSKIP SKIP NUMBER BETWEEN S.H. LATITUDES FROM SOUTH
64C> (DEFAULTS TO -IMAX IF JSSKIP=0)
65C> @param KWSKIP SKIP NUMBER BETWEEN WAVE FIELDS
66C> (DEFAULTS TO (MAXWV+1)*((IROMB+1)*MAXWV+2) IF KWSKIP=0)
67C> @param KGSKIP SKIP NUMBER BETWEEN GRID FIELDS
68C> (DEFAULTS TO IMAX*JMAX IF KGSKIP=0)
69C> @param JBEG LATITUDE INDEX (FROM POLE) TO BEGIN TRANSFORM
70C> - DEFAULTS TO 1 IF JBEG=0
71C> - IF JBEG=0 AND IDIR<0, WAVE IS ZEROED BEFORE TRANSFORM
72C> @param JEND LATITUDE INDEX (FROM POLE) TO END TRANSFORM
73C> (DEFAULTS TO (JMAX+1)/2 IF JEND=0)
74C> @param JCPU NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
75C> @param[out] WAVED (*) WAVE DIVERGENCE FIELDS IF IDIR>0
76C> [WAVED=(D(GRIDU)/DLAM+D(CLAT*GRIDV)/DPHI)/(CLAT*RERTH)]
77C> @param[out] WAVEZ (*) WAVE VORTICITY FIELDS IF IDIR>0
78C> [WAVEZ=(D(GRIDV)/DLAM-D(CLAT*GRIDU)/DPHI)/(CLAT*RERTH)]
79C> @param[out] GRIDUN N.H. GRID U-WINDS (STARTING AT JBEG) IF IDIR<0
80C> @param[out] GRIDUS S.H. GRID U-WINDS (STARTING AT JBEG) IF IDIR<0
81C> @param[out] GRIDVN N.H. GRID V-WINDS (STARTING AT JBEG) IF IDIR<0
82C> @param[out] GRIDVS S.H. GRID V-WINDS (STARTING AT JBEG) IF IDIR<0
83C> @param IDIR TRANSFORM FLAG
84C> - IDIR>0 FOR WAVE TO GRID,
85C> - IDIR<0 FOR GRID TO WAVE
86C>
87 SUBROUTINE sptranv(IROMB,MAXWV,IDRT,IMAX,JMAX,KMAX,
88 & IPRIME,ISKIP,JNSKIP,JSSKIP,KWSKIP,KGSKIP,
89 & JBEG,JEND,JCPU,
90 & WAVED,WAVEZ,GRIDUN,GRIDUS,GRIDVN,GRIDVS,IDIR)
91
92 REAL WAVED(*),WAVEZ(*),GRIDUN(*),GRIDUS(*),GRIDVN(*),GRIDVS(*)
93C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
94 MX=(maxwv+1)*((iromb+1)*maxwv+2)/2
95 ip=iprime
96 is=iskip
97 jn=jnskip
98 js=jsskip
99 kw=kwskip
100 kg=kgskip
101 jb=jbeg
102 je=jend
103 jc=jcpu
104 IF(ip.EQ.0) ip=1
105 IF(is.EQ.0) is=1
106 IF(jn.EQ.0) jn=imax
107 IF(js.EQ.0) js=-jn
108 IF(kw.EQ.0) kw=2*mx
109 IF(kg.EQ.0) kg=imax*jmax
110 IF(jb.EQ.0) jb=1
111 IF(je.EQ.0) je=(jmax+1)/2
112 IF(jc.EQ.0) jc=ncpus()
113C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
114 IF(idir.LT.0.AND.jbeg.EQ.0) THEN
115 DO k=1,kmax
116 kws=(k-1)*kw
117 waved(kws+1:kws+2*mx)=0
118 wavez(kws+1:kws+2*mx)=0
119 ENDDO
120 ENDIF
121C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
122 CALL sptranfv(iromb,maxwv,idrt,imax,jmax,kmax,
123 & ip,is,jn,js,kw,kg,jb,je,jc,
124 & waved,wavez,gridun,gridus,gridvn,gridvs,idir)
125C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
126 END
function ncpus()
Set number of CPUs - the number of processors over which to parallelize.
Definition: ncpus.F:24
subroutine sptranfv(IROMB, MAXWV, IDRT, IMAX, JMAX, KMAX, IP, IS, JN, JS, KW, KG, JB, JE, JC, WAVED, WAVEZ, GRIDUN, GRIDUS, GRIDVN, GRIDVS, IDIR)
This subprogram performs a spherical transform between spectral coefficients of divergences and curls...
Definition: sptranfv.f:83
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