NCEPLIBS-sp 2.4.0
sptrun.f
Go to the documentation of this file.
1C> @file
2C> @brief Truncate gridded scalar fields
3C> @author IREDELL @date 96-02-29
4
5C> This subprogram spectrally truncates scalar fields on a global
6C> cylindrical grid, returning the fields to a possibly different
7C> global cylindrical grid. The wave-space can be either triangular
8C> or rhomboidal. either grid-space can be either an equally-spaced
9C> grid (with or without pole points) or a Gaussian grid. the grid
10C> fields may have general indexing. the transforms are all
11C> multiprocessed. Transform several fields at a time to improve
12C> vectorization. Subprogram can be called from a multiprocessing
13C> environment.
14C>
15C> Remarks: Minimum grid dimensions for unaliased transforms to spectral:
16C> Dimension | Linear | Quadratic
17C> ----------------------- | --------- | -------------
18C> IMAX | 2*MAXWV+2 | 3*MAXWV/2*2+2
19C> JMAX (IDRT=4,IROMB=0) | 1*MAXWV+1 | 3*MAXWV/2+1
20C> JMAX (IDRT=4,IROMB=1) | 2*MAXWV+1 | 5*MAXWV/2+1
21C> JMAX (IDRT=0,IROMB=0) | 2*MAXWV+3 | 3*MAXWV/2*2+3
22C> JMAX (IDRT=0,IROMB=1) | 4*MAXWV+3 | 5*MAXWV/2*2+3
23C> JMAX (IDRT=256,IROMB=0) | 2*MAXWV+1 | 3*MAXWV/2*2+1
24C> JMAX (IDRT=256,IROMB=1) | 4*MAXWV+1 | 5*MAXWV/2*2+1
25C>
26C> @param IROMB Spectral domain shape (0 for triangular, 1 for rhomboidal)
27C> @param MAXWV Spectral truncation
28C> @param IDRTI Input grid identifier
29C> - IDRTI=4 for Gaussian grid
30C> - IDRTI=0 for equally-spaced grid including poles
31C> - IDRTI=256 for equally-spaced grid excluding poles
32C> @param IMAXI Even number of input longitudes
33C> @param JMAXI Number of input latitudes
34C> @param IDRTO Output grid identifier
35C> - IDRTO=4 for Gaussian grid
36C> - IDRTO=0 for equally-spaced grid including poles
37C> - IDRTO=256 for equally-spaced grid excluding poles
38C> @param IMAXO Even number of output longitudes
39C> @param JMAXO Number of output latitudes
40C> @param KMAX Number of fields to transform
41C> @param IPRIME Input longitude index for the prime meridian.
42C> - Defaults to 1 if IPRIME=0
43C> - Output longitude index for prime meridian assumed 1
44C> @param ISKIPI Skip number between input longitudes (defaults to 1 if ISKIPI=0)
45C> @param JSKIPI Skip number between input latitudes from south (defaults to -IMAXI if JSKIPI=0)
46C> @param KSKIPI Skip number between input grid fields (defaults to IMAXI*JMAXI if KSKIPI=0)
47C> @param ISKIPO Skip number between output longitudes (defaults to 1 if ISKIPO=0)
48C> @param JSKIPO Skip number between output latitudes from south (defaults to -IMAXO if JSKIPO=0)
49C> @param KSKIPO Skip number between output grid fields (defaults to IMAXO*JMAXO if KSKIPO=0)
50C> @param JCPU Number of CPUs over which to multiprocess (defaults to environment NCPUS if JCPU=0)
51C> @param GRIDI Input grid fields
52C> @param GRIDO Output grid fields (may overlay input fields if grid shape is appropriate)
53C>
54C> @author IREDELL @date 96-02-29
55 SUBROUTINE sptrun(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,IDRTO,IMAXO,JMAXO,
56 & KMAX,IPRIME,ISKIPI,JSKIPI,KSKIPI,
57 & ISKIPO,JSKIPO,KSKIPO,JCPU,GRIDI,GRIDO)
58 REAL GRIDI(*),GRIDO(*)
59 REAL W((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
60C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
61C TRANSFORM INPUT GRID TO WAVE
62 jc=jcpu
63 IF(jc.EQ.0) jc=ncpus()
64 mx=(maxwv+1)*((iromb+1)*maxwv+2)/2
65 mdim=2*mx+1
66 jn=-jskipi
67 IF(jn.EQ.0) jn=imaxi
68 js=-jn
69 inp=(jmaxi-1)*max(0,-jn)+1
70 isp=(jmaxi-1)*max(0,-js)+1
71 CALL sptran(iromb,maxwv,idrti,imaxi,jmaxi,kmax,
72 & iprime,iskipi,jn,js,mdim,kskipi,0,0,jc,
73 & w,gridi(inp),gridi(isp),-1)
74C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
75C TRANSFORM WAVE TO OUTPUT
76 jn=-jskipo
77 IF(jn.EQ.0) jn=imaxo
78 js=-jn
79 inp=(jmaxo-1)*max(0,-jn)+1
80 isp=(jmaxo-1)*max(0,-js)+1
81 CALL sptran(iromb,maxwv,idrto,imaxo,jmaxo,kmax,
82 & 0,iskipo,jn,js,mdim,kskipo,0,0,jc,
83 & w,grido(inp),grido(isp),1)
84C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
85 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 sptrun(IROMB, MAXWV, IDRTI, IMAXI, JMAXI, IDRTO, IMAXO, JMAXO, KMAX, IPRIME, ISKIPI, JSKIPI, KSKIPI, ISKIPO, JSKIPO, KSKIPO, JCPU, GRIDI, GRIDO)
This subprogram spectrally truncates scalar fields on a global cylindrical grid, returning the fields...
Definition: sptrun.f:58