NCEPLIBS-sp 2.4.0
sptran.f
Go to the documentation of this file.
1C> @file
2C> @brief Perform a scalar 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 between spectral
13C> coefficients of scalar quantities and fields on a global
14C> cylindrical grid.
15C>
16C> The wave-space can be either triangular or
17C> rhomboidal.
18C>
19C> The grid-space can be either an equally-spaced grid
20C> (with or without pole points) or a Gaussian grid.
21C>
22C> The wave and grid fields may have general indexing,
23C> but each wave field is in sequential 'IBM order',
24C> i.e. with zonal wavenumber as the slower index.
25C>
26C> Transforms are done in latitude pairs for efficiency;
27C> thus grid arrays for each hemisphere must be passed.
28C> If so requested, just a subset of the latitude pairs
29C> may be transformed in each invocation of the subprogram.
30C>
31C> The transforms are all multiprocessed over latitude except
32C> the transform from Fourier to spectral is multiprocessed
33C> over zonal wavenumber to ensure reproducibility.
34C>
35C> Transform several fields at a time to improve vectorization.
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)
73C> (if JBEG=0 and IDIR<0, wave is zeroed before transform)
74C> @param JEND latitude index (from pole) to end transform
75c> (defaults to (JMAX+1)/2 IF JEND=0)
76C> @param JCPU number of cpus over which to multiprocess
77C> @param[out] WAVE wave fields if IDIR>0
78C> @param[out] gridn n.h. grid fields (starting at jbeg) if IDIR<0
79C> @param[out] grids s.h. grid fields (starting at jbeg) if IDIR<0
80C> @param IDIR transform flag
81C> (idir>0 for wave to grid, idir<0 for grid to wave)
82C>
83C> @author IREDELL @date 96-02-29
84 SUBROUTINE sptran(IROMB,MAXWV,IDRT,IMAX,JMAX,KMAX,
85 & IPRIME,ISKIP,JNSKIP,JSSKIP,KWSKIP,KGSKIP,
86 & JBEG,JEND,JCPU,
87 & WAVE,GRIDN,GRIDS,IDIR)
88
89 REAL WAVE(*),GRIDN(*),GRIDS(*)
90
91 MX=(maxwv+1)*((iromb+1)*maxwv+2)/2
92 ip=iprime
93 is=iskip
94 jn=jnskip
95 js=jsskip
96 kw=kwskip
97 kg=kgskip
98 jb=jbeg
99 je=jend
100 jc=jcpu
101 IF(ip.EQ.0) ip=1
102 IF(is.EQ.0) is=1
103 IF(jn.EQ.0) jn=imax
104 IF(js.EQ.0) js=-jn
105 IF(kw.EQ.0) kw=2*mx
106 IF(kg.EQ.0) kg=imax*jmax
107 IF(jb.EQ.0) jb=1
108 IF(je.EQ.0) je=(jmax+1)/2
109 IF(jc.EQ.0) jc=ncpus()
110
111 IF(idir.LT.0.AND.jbeg.EQ.0) THEN
112 DO k=1,kmax
113 kws=(k-1)*kw
114 wave(kws+1:kws+2*mx)=0
115 ENDDO
116 ENDIF
117
118 CALL sptranf(iromb,maxwv,idrt,imax,jmax,kmax,
119 & ip,is,jn,js,kw,kg,jb,je,jc,
120 & wave,gridn,grids,idir)
121
122 END
function ncpus()
Set number of CPUs - the number of processors over which to parallelize.
Definition: ncpus.F:24
subroutine sptran(IROMB, MAXWV, IDRT, IMAX, JMAX, KMAX, IPRIME, ISKIP, JNSKIP, JSSKIP, KWSKIP, KGSKIP, JBEG, JEND, JCPU, WAVE, GRIDN, GRIDS, IDIR)
This subprogram performs a spherical transform between spectral coefficients of scalar quantities and...
Definition: sptran.f:88
subroutine sptranf(IROMB, MAXWV, IDRT, IMAX, JMAX, KMAX, IP, IS, JN, JS, KW, KG, JB, JE, JC, WAVE, GRIDN, GRIDS, IDIR)
This subprogram performs a spherical transform between spectral coefficients of scalar quantities and...
Definition: sptranf.f:77