NCEPLIBS-sp  2.3.3
sptrund.f
Go to the documentation of this file.
1 C> @file
2 C>
3 C> Spectrally truncate to gradients
4 C> @author IREDELL @date 96-02-29
5 
6 C> THIS SUBPROGRAM SPECTRALLY TRUNCATES SCALAR FIELDS
7 C> ON A GLOBAL CYLINDRICAL GRID, RETURNING THEIR MEANS AND
8 C> GRADIENTS TO A POSSIBLY DIFFERENT GLOBAL CYLINDRICAL GRID.
9 C> THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
10 C> EITHER GRID-SPACE CAN BE EITHER AN EQUALLY-SPACED GRID
11 C> (WITH OR WITHOUT POLE POINTS) OR A GAUSSIAN GRID.
12 C> THE GRID FIELDS MAY HAVE GENERAL INDEXING.
13 C> THE TRANSFORMS ARE ALL MULTIPROCESSED.
14 C> OVER ZONAL WAVENUMBER TO ENSURE REPRODUCIBILITY.
15 C> TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
16 C> SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
17 C>
18 C> @param IROMB - INTEGER SPECTRAL DOMAIN SHAPE
19 C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
20 C> @param MAXWV - INTEGER SPECTRAL TRUNCATION
21 C> @param IDRTI - INTEGER INPUT GRID IDENTIFIER
22 C> (IDRTI=4 FOR GAUSSIAN GRID,
23 C> IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
24 C> IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
25 C> @param IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
26 C> @param JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
27 C> @param IDRTO - INTEGER OUTPUT GRID IDENTIFIER
28 C> (IDRTO=4 FOR GAUSSIAN GRID,
29 C> IDRTO=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
30 C> IDRTO=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
31 C> @param IMAXO - INTEGER EVEN NUMBER OF OUTPUT LONGITUDES.
32 C> @param JMAXO - INTEGER NUMBER OF OUTPUT LATITUDES.
33 C> @param KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
34 C> @param IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
35 C> (DEFAULTS TO 1 IF IPRIME=0)
36 C> (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
37 C> @param ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
38 C> (DEFAULTS TO 1 IF ISKIPI=0)
39 C> @param JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
40 C> (DEFAULTS TO -IMAXI IF JSKIPI=0)
41 C> @param KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
42 C> (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
43 C> @param ISKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LONGITUDES
44 C> (DEFAULTS TO 1 IF ISKIPO=0)
45 C> @param JSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LATITUDES FROM SOUTH
46 C> (DEFAULTS TO -IMAXO IF JSKIPO=0)
47 C> @param KSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT GRID FIELDS
48 C> (DEFAULTS TO IMAXO*JMAXO IF KSKIPO=0)
49 C> @param JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
50 C> (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
51 C> @param GRID - REAL (*) INPUT GRID FIELDS
52 C> @param GRIDMN - REAL (KMAX) OUTPUT GLOBAL MEANS
53 C> @param GRIDX - REAL (*) OUTPUT X-GRADIENTS
54 C> @param GRIDY - REAL (*) OUTPUT Y-GRADIENTS
55 C>
56 C> SUBPROGRAMS CALLED:
57 C> - SPTRAN PERFORM A SCALAR SPHERICAL TRANSFORM
58 C> - SPTRAND PERFORM A GRADIENT SPHERICAL TRANSFORM
59 C> - NCPUS GETS ENVIRONMENT NUMBER OF CPUS
60 C>
61 C> REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
62 C> DIMENSION |LINEAR |QUADRATIC
63 C> ----------------------- |--------- |-------------
64 C> IMAX |2*MAXWV+2 |3*MAXWV/2*2+2
65 C> JMAX (IDRT=4,IROMB=0) |1*MAXWV+1 |3*MAXWV/2+1
66 C> JMAX (IDRT=4,IROMB=1) |2*MAXWV+1 |5*MAXWV/2+1
67 C> JMAX (IDRT=0,IROMB=0) |2*MAXWV+3 |3*MAXWV/2*2+3
68 C> JMAX (IDRT=0,IROMB=1) |4*MAXWV+3 |5*MAXWV/2*2+3
69 C> JMAX (IDRT=256,IROMB=0) |2*MAXWV+1 |3*MAXWV/2*2+1
70 C> JMAX (IDRT=256,IROMB=1) |4*MAXWV+1 |5*MAXWV/2*2+1
71  SUBROUTINE sptrund(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,
72  & IDRTO,IMAXO,JMAXO,KMAX,
73  & IPRIME,ISKIPI,JSKIPI,KSKIPI,
74  & ISKIPO,JSKIPO,KSKIPO,JCPU,GRID,
75  & GRIDMN,GRIDX,GRIDY)
76 
77  REAL GRID(*),GRIDX(*),GRIDY(*)
78  REAL W((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
79 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
80 C TRANSFORM INPUT GRID TO WAVE
81  jc=jcpu
82  IF(jc.EQ.0) jc=ncpus()
83  mx=(maxwv+1)*((iromb+1)*maxwv+2)/2
84  mdim=2*mx+1
85  jn=-jskipi
86  IF(jn.EQ.0) jn=imaxi
87  js=-jn
88  inp=(jmaxi-1)*max(0,-jn)+1
89  isp=(jmaxi-1)*max(0,-js)+1
90  CALL sptran(iromb,maxwv,idrti,imaxi,jmaxi,kmax,
91  & iprime,iskipi,jn,js,mdim,kskipi,0,0,jc,
92  & w,grid(inp),grid(isp),-1)
93 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
94 C TRANSFORM WAVE TO OUTPUT GRADIENTS
95  jn=-jskipo
96  IF(jn.EQ.0) jn=imaxo
97  js=-jn
98  inp=(jmaxo-1)*max(0,-jn)+1
99  isp=(jmaxo-1)*max(0,-js)+1
100  CALL sptrand(iromb,maxwv,idrto,imaxo,jmaxo,kmax,
101  & 0,iskipo,jn,js,mdim,kskipo,0,0,jc,
102  & w,gridmn,
103  & gridx(inp),gridx(isp),gridy(inp),gridy(isp),1)
104 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
105  END
sptrund
subroutine sptrund(IROMB, MAXWV, IDRTI, IMAXI, JMAXI, IDRTO, IMAXO, JMAXO, KMAX, IPRIME, ISKIPI, JSKIPI, KSKIPI, ISKIPO, JSKIPO, KSKIPO, JCPU, GRID, GRIDMN, GRIDX, GRIDY)
THIS SUBPROGRAM SPECTRALLY TRUNCATES SCALAR FIELDS ON A GLOBAL CYLINDRICAL GRID, RETURNING THEIR MEAN...
Definition: sptrund.f:76
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
sptrand
subroutine sptrand(IROMB, MAXWV, IDRT, IMAX, JMAX, KMAX, IPRIME, ISKIP, JNSKIP, JSSKIP, KWSKIP, KGSKIP, JBEG, JEND, JCPU, WAVE, GRIDMN, GRIDXN, GRIDXS, GRIDYN, GRIDYS, IDIR)
THIS SUBPROGRAM PERFORMS A SPHERICAL TRANSFORM BETWEEN SPECTRAL COEFFICIENTS OF SCALAR FIELDS AND THE...
Definition: sptrand.f:87