NCEPLIBS-sp  2.5.0
sptrun.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Truncate gridded scalar fields
3 C> @author IREDELL @date 96-02-29
4 
5 C> This subprogram spectrally truncates scalar fields on a global
6 C> cylindrical grid, returning the fields to a possibly different
7 C> global cylindrical grid. The wave-space can be either triangular
8 C> or rhomboidal. either grid-space can be either an equally-spaced
9 C> grid (with or without pole points) or a Gaussian grid. the grid
10 C> fields may have general indexing. the transforms are all
11 C> multiprocessed. Transform several fields at a time to improve
12 C> vectorization. Subprogram can be called from a multiprocessing
13 C> environment.
14 C>
15 C> Remarks: Minimum grid dimensions for unaliased transforms to spectral:
16 C> Dimension | Linear | Quadratic
17 C> ----------------------- | --------- | -------------
18 C> IMAX | 2*MAXWV+2 | 3*MAXWV/2*2+2
19 C> JMAX (IDRT=4,IROMB=0) | 1*MAXWV+1 | 3*MAXWV/2+1
20 C> JMAX (IDRT=4,IROMB=1) | 2*MAXWV+1 | 5*MAXWV/2+1
21 C> JMAX (IDRT=0,IROMB=0) | 2*MAXWV+3 | 3*MAXWV/2*2+3
22 C> JMAX (IDRT=0,IROMB=1) | 4*MAXWV+3 | 5*MAXWV/2*2+3
23 C> JMAX (IDRT=256,IROMB=0) | 2*MAXWV+1 | 3*MAXWV/2*2+1
24 C> JMAX (IDRT=256,IROMB=1) | 4*MAXWV+1 | 5*MAXWV/2*2+1
25 C>
26 C> @param IROMB Spectral domain shape (0 for triangular, 1 for rhomboidal)
27 C> @param MAXWV Spectral truncation
28 C> @param IDRTI Input grid identifier
29 C> - IDRTI=4 for Gaussian grid
30 C> - IDRTI=0 for equally-spaced grid including poles
31 C> - IDRTI=256 for equally-spaced grid excluding poles
32 C> @param IMAXI Even number of input longitudes
33 C> @param JMAXI Number of input latitudes
34 C> @param IDRTO Output grid identifier
35 C> - IDRTO=4 for Gaussian grid
36 C> - IDRTO=0 for equally-spaced grid including poles
37 C> - IDRTO=256 for equally-spaced grid excluding poles
38 C> @param IMAXO Even number of output longitudes
39 C> @param JMAXO Number of output latitudes
40 C> @param KMAX Number of fields to transform
41 C> @param IPRIME Input longitude index for the prime meridian.
42 C> - Defaults to 1 if IPRIME=0
43 C> - Output longitude index for prime meridian assumed 1
44 C> @param ISKIPI Skip number between input longitudes (defaults to 1 if ISKIPI=0)
45 C> @param JSKIPI Skip number between input latitudes from south (defaults to -IMAXI if JSKIPI=0)
46 C> @param KSKIPI Skip number between input grid fields (defaults to IMAXI*JMAXI if KSKIPI=0)
47 C> @param ISKIPO Skip number between output longitudes (defaults to 1 if ISKIPO=0)
48 C> @param JSKIPO Skip number between output latitudes from south (defaults to -IMAXO if JSKIPO=0)
49 C> @param KSKIPO Skip number between output grid fields (defaults to IMAXO*JMAXO if KSKIPO=0)
50 C> @param JCPU Number of CPUs over which to multiprocess (defaults to environment NCPUS if JCPU=0)
51 C> @param GRIDI Input grid fields
52 C> @param GRIDO Output grid fields (may overlay input fields if grid shape is appropriate)
53 C>
54 C> @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)
60 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
61 C 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)
74 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
75 C 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)
84 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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