NCEPLIBS-sp  2.3.3
sptrun.f
Go to the documentation of this file.
1 C> @file
2 C>
3 C> truncate gridded scalar fields.
4 C> @author: IREDELL @date: 96-02-29
5 
6 C> This subprogram spectrally truncates scalar fields on a global
7 C> cylindrical grid, returning the fields to a possibly different
8 C> global cylindrical grid. The wave-space can be either triangular
9 C> or rhomboidal. either grid-space can be either an equally-spaced
10 C> grid (with or without pole points) or a gaussian grid. the grid
11 C> fields may have general indexing. the transforms are all
12 C> multiprocessed. Transform several fields at a time to improve
13 C> vectorization. Subprogram can be called from a multiprocessing
14 C> environment.
15 C>
16 C>
17 C> @param IROMB - INTEGER SPECTRAL DOMAIN SHAPE
18 C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
19 C> @param MAXWV - INTEGER SPECTRAL TRUNCATION
20 C> @param IDRTI - INTEGER INPUT GRID IDENTIFIER
21 C> (IDRTI=4 FOR GAUSSIAN GRID,
22 C> IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
23 C> IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
24 C> @param IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
25 C> @param JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
26 C> @param IDRTO - INTEGER OUTPUT GRID IDENTIFIER
27 C> (IDRTO=4 FOR GAUSSIAN GRID,
28 C> IDRTO=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
29 C> IDRTO=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
30 C> @param IMAXO - INTEGER EVEN NUMBER OF OUTPUT LONGITUDES.
31 C> @param JMAXO - INTEGER NUMBER OF OUTPUT LATITUDES.
32 C> @param KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
33 C> @param IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
34 C> (DEFAULTS TO 1 IF IPRIME=0)
35 C> (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
36 C> @param ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
37 C> (DEFAULTS TO 1 IF ISKIPI=0)
38 C> @param JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
39 C> (DEFAULTS TO -IMAXI IF JSKIPI=0)
40 C> @param KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
41 C> (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
42 C> @param ISKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LONGITUDES
43 C> (DEFAULTS TO 1 IF ISKIPO=0)
44 C> @param JSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LATITUDES FROM SOUTH
45 C> (DEFAULTS TO -IMAXO IF JSKIPO=0)
46 C> @param KSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT GRID FIELDS
47 C> (DEFAULTS TO IMAXO*JMAXO IF KSKIPO=0)
48 C> @param JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
49 C> (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
50 C> @param GRIDI - REAL (*) INPUT GRID FIELDS
51 C> @param GRIDO - REAL (*) OUTPUT GRID FIELDS
52 C> (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
53 C>
54 C> CALLED:
55 C> SPTRAN PERFORM A SCALAR SPHERICAL TRANSFORM
56 C> NCPUS GETS ENVIRONMENT NUMBER OF CPUS
57 C>
58 C> REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
59 C> DIMENSION LINEAR QUADRATIC
60 C> ----------------------- --------- -------------
61 C> IMAX 2*MAXWV+2 3*MAXWV/2*2+2
62 C> JMAX (IDRT=4,IROMB=0) 1*MAXWV+1 3*MAXWV/2+1
63 C> JMAX (IDRT=4,IROMB=1) 2*MAXWV+1 5*MAXWV/2+1
64 C> JMAX (IDRT=0,IROMB=0) 2*MAXWV+3 3*MAXWV/2*2+3
65 C> JMAX (IDRT=0,IROMB=1) 4*MAXWV+3 5*MAXWV/2*2+3
66 C> JMAX (IDRT=256,IROMB=0) 2*MAXWV+1 3*MAXWV/2*2+1
67 C> JMAX (IDRT=256,IROMB=1) 4*MAXWV+1 5*MAXWV/2*2+1
68  SUBROUTINE sptrun(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,IDRTO,IMAXO,JMAXO,
69  & KMAX,IPRIME,ISKIPI,JSKIPI,KSKIPI,
70  & ISKIPO,JSKIPO,KSKIPO,JCPU,GRIDI,GRIDO)
71  REAL GRIDI(*),GRIDO(*)
72  REAL W((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
73 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
74 C TRANSFORM INPUT GRID TO WAVE
75  jc=jcpu
76  IF(jc.EQ.0) jc=ncpus()
77  mx=(maxwv+1)*((iromb+1)*maxwv+2)/2
78  mdim=2*mx+1
79  jn=-jskipi
80  IF(jn.EQ.0) jn=imaxi
81  js=-jn
82  inp=(jmaxi-1)*max(0,-jn)+1
83  isp=(jmaxi-1)*max(0,-js)+1
84  CALL sptran(iromb,maxwv,idrti,imaxi,jmaxi,kmax,
85  & iprime,iskipi,jn,js,mdim,kskipi,0,0,jc,
86  & w,gridi(inp),gridi(isp),-1)
87 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
88 C TRANSFORM WAVE TO OUTPUT
89  jn=-jskipo
90  IF(jn.EQ.0) jn=imaxo
91  js=-jn
92  inp=(jmaxo-1)*max(0,-jn)+1
93  isp=(jmaxo-1)*max(0,-js)+1
94  CALL sptran(iromb,maxwv,idrto,imaxo,jmaxo,kmax,
95  & 0,iskipo,jn,js,mdim,kskipo,0,0,jc,
96  & w,grido(inp),grido(isp),1)
97 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98  END
sptran
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:80
ncpus
function ncpus()
Set number of cpus.
Definition: ncpus.F:21
sptrun
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:71