NCEPLIBS-sp 2.4.0
sptrungv.f
Go to the documentation of this file.
1C> @file
2C>
3C> Spectrally interpolate vectors to stations
4C> @author IREDELL @date 96-02-29
5
6C> THIS SUBPROGRAM SPECTRALLY TRUNCATES VECTORS FIELDS
7C> ON A GLOBAL CYLINDRICAL GRID, RETURNING THE FIELDS
8C> TO SPECIFIED SETS OF STATION POINTS ON THE GLOBE.
9C> THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
10C> THE GRID-SPACE CAN BE EITHER AN EQUALLY-SPACED GRID
11C> (WITH OR WITHOUT POLE POINTS) OR A GAUSSIAN GRID.
12C> THE GRID AND POINT FIELDS MAY HAVE GENERAL INDEXING.
13C> THE TRANSFORMS ARE ALL MULTIPROCESSED.
14C> TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
15C> SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
16C>
17C> PROGRAM HISTORY LOG:
18C> - 96-02-29 IREDELL
19C> - 1998-12-15 IREDELL OPENMP DIRECTIVES INSERTED
20C>
21C> @param IROMB - INTEGER SPECTRAL DOMAIN SHAPE
22C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
23C> @param MAXWV - INTEGER SPECTRAL TRUNCATION
24C> @param IDRTI - INTEGER INPUT GRID IDENTIFIER
25C> (IDRTI=4 FOR GAUSSIAN GRID,
26C> IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
27C> IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
28C> @param IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
29C> @param JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
30C> @param KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
31C> @param NMAX - INTEGER NUMBER OF STATION POINTS TO RETURN
32C> @param IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
33C> (DEFAULTS TO 1 IF IPRIME=0)
34C> (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
35C> @param ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
36C> (DEFAULTS TO 1 IF ISKIPI=0)
37C> @param JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
38C> (DEFAULTS TO -IMAXI IF JSKIPI=0)
39C> @param KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
40C> (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
41C> @param KGSKIP - INTEGER SKIP NUMBER BETWEEN STATION POINT SETS
42C> (DEFAULTS TO NMAX IF KGSKIP=0)
43C> @param NRSKIP - INTEGER SKIP NUMBER BETWEEN STATION LATS AND LONS
44C> (DEFAULTS TO 1 IF NRSKIP=0)
45C> @param NGSKIP - INTEGER SKIP NUMBER BETWEEN STATION POINTS
46C> (DEFAULTS TO 1 IF NGSKIP=0)
47C> @param RLAT - REAL (*) STATION LATITUDES IN DEGREES
48C> @param RLON - REAL (*) STATION LONGITUDES IN DEGREES
49C> @param JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
50C> (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
51C> @param GRIDUI - REAL (*) INPUT GRID U-WINDS
52C> @param GRIDVI - REAL (*) INPUT GRID V-WINDS
53C> @param LUV - LOGICAL FLAG WHETHER TO RETURN WINDS
54C> @param LDZ - LOGICAL FLAG WHETHER TO RETURN DIVERGENCE AND VORTICITY
55C> @param LPS - LOGICAL FLAG WHETHER TO RETURN POTENTIAL AND STREAMFCN
56C> @param UP - REAL (*) STATION U-WINDS IF LUV
57C> @param VP - REAL (*) STATION V-WINDS IF LUV
58C> @param DP - REAL (*) STATION DIVERGENCES IF LDZ
59C> @param ZP - REAL (*) STATION VORTICITIES IF LDZ
60C> @param PP - REAL (*) STATION POTENTIALS IF LPS
61C> @param SP - REAL (*) STATION STREAMFCNS IF LPS
62C>
63C> SUBPROGRAMS CALLED:
64C> - SPWGET GET WAVE-SPACE CONSTANTS
65C> - SPLAPLAC COMPUTE LAPLACIAN IN SPECTRAL SPACE
66C> - SPTRANV PERFORM A VECTOR SPHERICAL TRANSFORM
67C> - SPTGPT TRANSFORM SPECTRAL SCALAR TO STATION POINTS
68C> - SPTGPTV TRANSFORM SPECTRAL VECTOR TO STATION POINTS
69C> - NCPUS GETS ENVIRONMENT NUMBER OF CPUS
70C>
71C> REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
72C> DIMENSION |LINEAR |QUADRATIC
73C> ----------------------- |--------- |-------------
74C> IMAX |2*MAXWV+2 |3*MAXWV/2*2+2
75C> JMAX (IDRT=4,IROMB=0) |1*MAXWV+1 |3*MAXWV/2+1
76C> JMAX (IDRT=4,IROMB=1) |2*MAXWV+1 |5*MAXWV/2+1
77C> JMAX (IDRT=0,IROMB=0) |2*MAXWV+3 |3*MAXWV/2*2+3
78C> JMAX (IDRT=0,IROMB=1) |4*MAXWV+3 |5*MAXWV/2*2+3
79C> JMAX (IDRT=256,IROMB=0) |2*MAXWV+1 |3*MAXWV/2*2+1
80C> JMAX (IDRT=256,IROMB=1) |4*MAXWV+1 |5*MAXWV/2*2+1
81 SUBROUTINE sptrungv(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,KMAX,NMAX,
82 & IPRIME,ISKIPI,JSKIPI,KSKIPI,KGSKIP,
83 & NRSKIP,NGSKIP,JCPU,RLAT,RLON,GRIDUI,GRIDVI,
84 & LUV,UP,VP,LDZ,DP,ZP,LPS,PP,SP)
85
86 LOGICAL LUV,LDZ,LPS
87 REAL RLAT(*),RLON(*),GRIDUI(*),GRIDVI(*)
88 REAL UP(*),VP(*),DP(*),ZP(*),PP(*),SP(*)
89 REAL EPS((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EPSTOP(MAXWV+1)
90 REAL ENN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
91 REAL ELONN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
92 REAL EON((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EONTOP(MAXWV+1)
93 REAL WD((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
94 REAL WZ((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
95C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
96C TRANSFORM INPUT GRID TO WAVE
97 jc=jcpu
98 IF(jc.EQ.0) jc=ncpus()
99 mx=(maxwv+1)*((iromb+1)*maxwv+2)/2
100 mdim=2*mx+1
101 jn=-jskipi
102 IF(jn.EQ.0) jn=imaxi
103 js=-jn
104 inp=(jmaxi-1)*max(0,-jn)+1
105 isp=(jmaxi-1)*max(0,-js)+1
106 CALL sptranv(iromb,maxwv,idrti,imaxi,jmaxi,kmax,
107 & iprime,iskipi,jn,js,mdim,kskipi,0,0,jc,
108 & wd,wz,
109 & gridui(inp),gridui(isp),gridvi(inp),gridvi(isp),-1)
110C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
111C TRANSFORM WAVE TO OUTPUT WINDS
112 IF(luv) THEN
113 CALL sptgptv(iromb,maxwv,kmax,nmax,mdim,kgskip,nrskip,ngskip,
114 & rlat,rlon,wd,wz,up,vp)
115 ENDIF
116C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
117C TRANSFORM WAVE TO OUTPUT DIVERGENCE AND VORTICITY
118 IF(ldz) THEN
119 CALL sptgpt(iromb,maxwv,kmax,nmax,mdim,kgskip,nrskip,ngskip,
120 & rlat,rlon,wd,dp)
121 CALL sptgpt(iromb,maxwv,kmax,nmax,mdim,kgskip,nrskip,ngskip,
122 & rlat,rlon,wz,zp)
123 ENDIF
124C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
125C TRANSFORM WAVE TO OUTPUT POTENTIAL AND STREAMFUNCTION
126 IF(lps) THEN
127 CALL spwget(iromb,maxwv,eps,epstop,enn1,elonn1,eon,eontop)
128C$OMP PARALLEL DO
129 DO k=1,kmax
130 CALL splaplac(iromb,maxwv,enn1,wd(1,k),wd(1,k),-1)
131 CALL splaplac(iromb,maxwv,enn1,wz(1,k),wz(1,k),-1)
132 wd(1:2,k)=0.
133 wz(1:2,k)=0.
134 ENDDO
135 CALL sptgpt(iromb,maxwv,kmax,nmax,mdim,kgskip,nrskip,ngskip,
136 & rlat,rlon,wd,pp)
137 CALL sptgpt(iromb,maxwv,kmax,nmax,mdim,kgskip,nrskip,ngskip,
138 & rlat,rlon,wz,sp)
139 ENDIF
140C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
141 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 sptgpt(IROMB, MAXWV, KMAX, NMAX, KWSKIP, KGSKIP, NRSKIP, NGSKIP, RLAT, RLON, WAVE, GP)
This subprogram performs a spherical transform from spectral coefficients of scalar quantities to spe...
Definition: sptgpt.f:51
subroutine sptgptv(IROMB, MAXWV, KMAX, NMAX, KWSKIP, KGSKIP, NRSKIP, NGSKIP, RLAT, RLON, WAVED, WAVEZ, UP, VP)
This subprogram performs a spherical transform from spectral coefficients of divergences and curls to...
Definition: sptgptv.f:54
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 sptrungv(IROMB, MAXWV, IDRTI, IMAXI, JMAXI, KMAX, NMAX, IPRIME, ISKIPI, JSKIPI, KSKIPI, KGSKIP, NRSKIP, NGSKIP, JCPU, RLAT, RLON, GRIDUI, GRIDVI, LUV, UP, VP, LDZ, DP, ZP, LPS, PP, SP)
THIS SUBPROGRAM SPECTRALLY TRUNCATES VECTORS FIELDS ON A GLOBAL CYLINDRICAL GRID, RETURNING THE FIELD...
Definition: sptrungv.f:85
subroutine spwget(IROMB, MAXWV, EPS, EPSTOP, ENN1, ELONN1, EON, EONTOP)
This subprogram gets wave-space constants.
Definition: spwget.f:18