NCEPLIBS-sp  2.5.0
sptran.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Perform a scalar spherical transform.
3 C>
4 C> ### Program History Log
5 C> Date | Programmer | Comments
6 C> -----|------------|---------
7 C> 96-02-29 | IREDELL | Initial
8 C> 1998-12-15 | IREDELL | Generic fft used, openmp directives inserted
9 C>
10 C> @author IREDELL @date 96-02-29
11 
12 C> This subprogram performs a spherical transform between spectral
13 C> coefficients of scalar quantities and fields on a global
14 C> cylindrical grid.
15 C>
16 C> The wave-space can be either triangular or
17 C> rhomboidal.
18 C>
19 C> The grid-space can be either an equally-spaced grid
20 C> (with or without pole points) or a Gaussian grid.
21 C>
22 C> The wave and grid fields may have general indexing,
23 C> but each wave field is in sequential 'IBM order',
24 C> i.e. with zonal wavenumber as the slower index.
25 C>
26 C> Transforms are done in latitude pairs for efficiency;
27 C> thus grid arrays for each hemisphere must be passed.
28 C> If so requested, just a subset of the latitude pairs
29 C> may be transformed in each invocation of the subprogram.
30 C>
31 C> The transforms are all multiprocessed over latitude except
32 C> the transform from Fourier to spectral is multiprocessed
33 C> over zonal wavenumber to ensure reproducibility.
34 C>
35 C> Transform several fields at a time to improve vectorization.
36 C> Subprogram can be called from a multiprocessing environment.
37 C>
38 C> Minimum grid dimensions for unaliased transforms to spectral:
39 C> DIMENSION |LINEAR |QUADRATIC
40 C> ----------------------- |--------- |-------------
41 C> IMAX | 2*MAXWV+2 | 3*MAXWV/2*2+2
42 C> JMAX (IDRT=4,IROMB=0) | 1*MAXWV+1 | 3*MAXWV/2+1
43 C> JMAX (IDRT=4,IROMB=1) | 2*MAXWV+1 | 5*MAXWV/2+1
44 C> JMAX (IDRT=0,IROMB=0) | 2*MAXWV+3 | 3*MAXWV/2*2+3
45 C> JMAX (IDRT=0,IROMB=1) | 4*MAXWV+3 | 5*MAXWV/2*2+3
46 C> JMAX (IDRT=256,IROMB=0) | 2*MAXWV+1 | 3*MAXWV/2*2+1
47 C> JMAX (IDRT=256,IROMB=1) | 4*MAXWV+1 | 5*MAXWV/2*2+1
48 C>
49 C> @param IROMB spectral domain shape
50 c> (0 for triangular, 1 for rhomboidal)
51 C> @param MAXWV spectral truncation
52 C> @param IDRT grid identifier
53 C> - IDRT=4 for Gaussian grid,
54 C> - IDRT=0 for equally-spaced grid including poles,
55 C> - IDRT=256 for equally-spaced grid excluding poles
56 C> @param IMAX even number of longitudes.
57 C> @param JMAX number of latitudes.
58 C> @param KMAX number of fields to transform.
59 C> @param IPRIME longitude index for the prime meridian.
60 C> (defaults to 1 if IPRIME=0)
61 C> @param ISKIP skip number between longitudes
62 C> (defaults to 1 if ISKIP=0)
63 C> @param JNSKIP skip number between n.h. latitudes from north
64 C> (defaults to imax if JNSKIP=0)
65 C> @param JSSKIP skip number between s.h. latitudes from south
66 c> (defaults to -imax if JSSKIP=0)
67 C> @param KWSKIP skip number between wave fields
68 c> (defaults to (MAXWV+1)*((IROMB+1)*MAXWV+2) IF KWSKIP=0)
69 C> @param KGSKIP skip number between grid fields
70 c> (defaults to IMAX*JMAX IF KGSKIP=0)
71 C> @param JBEG latitude index (from pole) to begin transform
72 c> (defaults to 1 if JBEG=0)
73 C> (if JBEG=0 and IDIR<0, wave is zeroed before transform)
74 C> @param JEND latitude index (from pole) to end transform
75 c> (defaults to (JMAX+1)/2 IF JEND=0)
76 C> @param JCPU number of cpus over which to multiprocess
77 C> @param[out] WAVE wave fields if IDIR>0
78 C> @param[out] gridn n.h. grid fields (starting at jbeg) if IDIR<0
79 C> @param[out] grids s.h. grid fields (starting at jbeg) if IDIR<0
80 C> @param IDIR transform flag
81 C> (idir>0 for wave to grid, idir<0 for grid to wave)
82 C>
83 C> @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