NCEPLIBS-sp 2.4.0
sptrunv.f
Go to the documentation of this file.
1C> @file
2C>
3C> Spectrally truncate gridded vector fields
4C> @author IREDELL @date 96-02-29
5
6C> This subprogram spectrally truncates vector fields
7C> on a global cylindrical grid, returning the fields
8C> to a possibly different global cylindrical grid.
9C> The wave-space can be either triangular or rhomboidal.
10C> Either grid-space can be either an equally-spaced grid
11C> (with or without pole points) or a Gaussian grid.
12C> The grid fields may have general indexing.
13C> The transforms are all multiprocessed.
14C> Over zonal wavenumber to ensure reproducibility.
15C> Transform several fields at a time to improve vectorization.
16C> Subprogram can be called from a multiprocessing environment.
17C>
18C> PROGRAM HISTORY LOG:
19C> - 96-02-29 IREDELL
20C> - 1998-12-15 IREDELL OPENMP DIRECTIVES INSERTED
21C>
22C> @param IROMB - INTEGER SPECTRAL DOMAIN SHAPE
23C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
24C> @param MAXWV - INTEGER SPECTRAL TRUNCATION
25C> @param IDRTI - INTEGER INPUT GRID IDENTIFIER
26C> (IDRTI=4 FOR GAUSSIAN GRID,
27C> IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
28C> IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
29C> @param IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
30C> @param JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
31C> @param IDRTO - INTEGER OUTPUT GRID IDENTIFIER
32C> (IDRTO=4 FOR GAUSSIAN GRID,
33C> IDRTO=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
34C> IDRTO=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
35C> @param IMAXO - INTEGER EVEN NUMBER OF OUTPUT LONGITUDES.
36C> @param JMAXO - INTEGER NUMBER OF OUTPUT LATITUDES.
37C> @param KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
38C> @param IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
39C> (DEFAULTS TO 1 IF IPRIME=0)
40C> (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
41C> @param ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
42C> (DEFAULTS TO 1 IF ISKIPI=0)
43C> @param JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
44C> (DEFAULTS TO -IMAXI IF JSKIPI=0)
45C> @param KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
46C> (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
47C> @param ISKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LONGITUDES
48C> (DEFAULTS TO 1 IF ISKIPO=0)
49C> @param JSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LATITUDES FROM SOUTH
50C> (DEFAULTS TO -IMAXO IF JSKIPO=0)
51C> @param KSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT GRID FIELDS
52C> (DEFAULTS TO IMAXO*JMAXO IF KSKIPO=0)
53C> @param JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
54C> (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
55C> @param GRIDUI - REAL (*) INPUT GRID U-WINDS
56C> @param GRIDVI - REAL (*) INPUT GRID V-WINDS
57C> @param LUV - LOGICAL FLAG WHETHER TO RETURN WINDS
58C> @param LDZ - LOGICAL FLAG WHETHER TO RETURN DIVERGENCE AND VORTICITY
59C> @param LPS - LOGICAL FLAG WHETHER TO RETURN POTENTIAL AND STREAMFCN
60C> @param GRIDUO - REAL (*) OUTPUT U-WINDS IF LUV
61C> (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
62C> @param GRIDVO - REAL (*) OUTPUT V-WINDS IF LUV
63C> (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
64C> @param GRIDDO - REAL (*) OUTPUT DIVERGENCES IF LDZ
65C> (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
66C> @param GRIDZO - REAL (*) OUTPUT VORTICITIES IF LDZ
67C> (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
68C> @param GRIDPO - REAL (*) OUTPUT POTENTIALS IF LPS
69C> (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
70C> @param GRIDSO - REAL (*) OUTPUT STREAMFCNS IF LPS
71C> (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
72C>
73C> SUBPROGRAMS CALLED:
74C> - SPWGET() GET WAVE-SPACE CONSTANTS
75C> - SPLAPLAC() COMPUTE LAPLACIAN IN SPECTRAL SPACE
76C> - SPTRAN() PERFORM A SCALAR SPHERICAL TRANSFORM
77C> - SPTRANV() PERFORM A VECTOR SPHERICAL TRANSFORM
78C> - NCPUS() GETS ENVIRONMENT NUMBER OF CPUS
79C>
80C> REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
81C> DIMENSION |LINEAR |QUADRATIC
82C> ----------------------- |--------- |-------------
83C> IMAX |2*MAXWV+2 |3*MAXWV/2*2+2
84C> JMAX (IDRT=4,IROMB=0) |1*MAXWV+1 |3*MAXWV/2+1
85C> JMAX (IDRT=4,IROMB=1) |2*MAXWV+1 |5*MAXWV/2+1
86C> JMAX (IDRT=0,IROMB=0) |2*MAXWV+3 |3*MAXWV/2*2+3
87C> JMAX (IDRT=0,IROMB=1) |4*MAXWV+3 |5*MAXWV/2*2+3
88C> JMAX (IDRT=256,IROMB=0) |2*MAXWV+1 |3*MAXWV/2*2+1
89C> JMAX (IDRT=256,IROMB=1) |4*MAXWV+1 |5*MAXWV/2*2+1
90 SUBROUTINE sptrunv(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,
91 & IDRTO,IMAXO,JMAXO,KMAX,
92 & IPRIME,ISKIPI,JSKIPI,KSKIPI,
93 & ISKIPO,JSKIPO,KSKIPO,JCPU,GRIDUI,GRIDVI,
94 & LUV,GRIDUO,GRIDVO,LDZ,GRIDDO,GRIDZO,
95 & LPS,GRIDPO,GRIDSO)
96 LOGICAL LUV,LDZ,LPS
97 REAL GRIDUI(*),GRIDVI(*)
98 REAL GRIDUO(*),GRIDVO(*),GRIDDO(*),GRIDZO(*),GRIDPO(*),GRIDSO(*)
99 REAL EPS((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EPSTOP(MAXWV+1)
100 REAL ENN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
101 REAL ELONN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
102 REAL EON((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EONTOP(MAXWV+1)
103 REAL WD((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
104 REAL WZ((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
105C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106C TRANSFORM INPUT GRID TO WAVE
107 jc=jcpu
108 IF(jc.EQ.0) jc=ncpus()
109 mx=(maxwv+1)*((iromb+1)*maxwv+2)/2
110 mdim=2*mx+1
111 jn=-jskipi
112 IF(jn.EQ.0) jn=imaxi
113 js=-jn
114 inp=(jmaxi-1)*max(0,-jn)+1
115 isp=(jmaxi-1)*max(0,-js)+1
116 CALL sptranv(iromb,maxwv,idrti,imaxi,jmaxi,kmax,
117 & iprime,iskipi,jn,js,mdim,kskipi,0,0,jc,
118 & wd,wz,
119 & gridui(inp),gridui(isp),gridvi(inp),gridvi(isp),-1)
120C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
121C TRANSFORM WAVE TO OUTPUT WINDS
122 jn=-jskipo
123 IF(jn.EQ.0) jn=imaxo
124 js=-jn
125 inp=(jmaxo-1)*max(0,-jn)+1
126 isp=(jmaxo-1)*max(0,-js)+1
127 IF(luv) THEN
128 CALL sptranv(iromb,maxwv,idrto,imaxo,jmaxo,kmax,
129 & 0,iskipo,jn,js,mdim,kskipo,0,0,jc,
130 & wd,wz,
131 & griduo(inp),griduo(isp),gridvo(inp),gridvo(isp),1)
132 ENDIF
133C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
134C TRANSFORM WAVE TO OUTPUT DIVERGENCE AND VORTICITY
135 IF(ldz) THEN
136 CALL sptran(iromb,maxwv,idrto,imaxo,jmaxo,kmax,
137 & 0,iskipo,jn,js,mdim,kskipo,0,0,jc,
138 & wd,griddo(inp),griddo(isp),1)
139 CALL sptran(iromb,maxwv,idrto,imaxo,jmaxo,kmax,
140 & 0,iskipo,jn,js,mdim,kskipo,0,0,jc,
141 & wz,gridzo(inp),gridzo(isp),1)
142 ENDIF
143C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
144C TRANSFORM WAVE TO OUTPUT POTENTIAL AND STREAMFUNCTION
145 IF(lps) THEN
146 CALL spwget(iromb,maxwv,eps,epstop,enn1,elonn1,eon,eontop)
147C$OMP PARALLEL DO
148 DO k=1,kmax
149 CALL splaplac(iromb,maxwv,enn1,wd(1,k),wd(1,k),-1)
150 CALL splaplac(iromb,maxwv,enn1,wz(1,k),wz(1,k),-1)
151 wd(1:2,k)=0.
152 wz(1:2,k)=0.
153 ENDDO
154 CALL sptran(iromb,maxwv,idrto,imaxo,jmaxo,kmax,
155 & 0,iskipo,jn,js,mdim,kskipo,0,0,jc,
156 & wd,gridpo(inp),gridpo(isp),1)
157 CALL sptran(iromb,maxwv,idrto,imaxo,jmaxo,kmax,
158 & 0,iskipo,jn,js,mdim,kskipo,0,0,jc,
159 & wz,gridso(inp),gridso(isp),1)
160 ENDIF
161C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
162 END
function ncpus()
Set number of CPUs - the number of processors over which to parallelize.
Definition: ncpus.F:24
subroutine splaplac(I, M, ENN1, Q, QD2, IDIR)
Computes the laplacian or the inverse laplacian of a scalar field in spectral space.
Definition: splaplac.f:25
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 sptranv(IROMB, MAXWV, IDRT, IMAX, JMAX, KMAX, IPRIME, ISKIP, JNSKIP, JSSKIP, KWSKIP, KGSKIP, JBEG, JEND, JCPU, WAVED, WAVEZ, GRIDUN, GRIDUS, GRIDVN, GRIDVS, IDIR)
This subprogram performs a spherical transform between spectral coefficients of divergences and curls...
Definition: sptranv.f:91
subroutine sptrunv(IROMB, MAXWV, IDRTI, IMAXI, JMAXI, IDRTO, IMAXO, JMAXO, KMAX, IPRIME, ISKIPI, JSKIPI, KSKIPI, ISKIPO, JSKIPO, KSKIPO, JCPU, GRIDUI, GRIDVI, LUV, GRIDUO, GRIDVO, LDZ, GRIDDO, GRIDZO, LPS, GRIDPO, GRIDSO)
This subprogram spectrally truncates vector fields on a global cylindrical grid, returning the fields...
Definition: sptrunv.f:96
subroutine spwget(IROMB, MAXWV, EPS, EPSTOP, ENN1, ELONN1, EON, EONTOP)
This subprogram gets wave-space constants.
Definition: spwget.f:18