NCEPLIBS-sp  2.3.3
sptrunsv.f
Go to the documentation of this file.
1 C> @file
2 C>
3 C> Spectrally interpolate vectors to polar stereo
4 C> @author IREDELL @date 96-02-29
5 
6 C> THIS SUBPROGRAM SPECTRALLY TRUNCATES VECTOR FIELDS
7 C> ON A GLOBAL CYLINDRICAL GRID, RETURNING THE FIELDS
8 C> TO SPECIFIC PAIRS OF POLAR STEREOGRAPHIC SCALAR FIELDS.
9 C> THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
10 C> THE 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> TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
15 C> SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
16 C>
17 C> PROGRAM HISTORY LOG:
18 C> - 96-02-29 IREDELL
19 C> - 1998-12-15 IREDELL OPENMP DIRECTIVES INSERTED
20 C>
21 C> @param IROMB - INTEGER SPECTRAL DOMAIN SHAPE
22 C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
23 C> @param MAXWV - INTEGER SPECTRAL TRUNCATION
24 C> @param IDRTI - INTEGER INPUT GRID IDENTIFIER
25 C> (IDRTI=4 FOR GAUSSIAN GRID,
26 C> IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
27 C> IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
28 C> @param IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
29 C> @param JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
30 C> @param KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
31 C> @param NPS - INTEGER ODD ORDER OF THE POLAR STEREOGRAPHIC GRIDS
32 C> @param IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
33 C> (DEFAULTS TO 1 IF IPRIME=0)
34 C> (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
35 C> @param ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
36 C> (DEFAULTS TO 1 IF ISKIPI=0)
37 C> @param JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
38 C> (DEFAULTS TO -IMAXI IF JSKIPI=0)
39 C> @param KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
40 C> (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
41 C> @param KGSKIP - INTEGER SKIP NUMBER BETWEEN GRID FIELDS
42 C> (DEFAULTS TO NPS*NPS IF KGSKIP=0)
43 C> @param NISKIP - INTEGER SKIP NUMBER BETWEEN GRID I-POINTS
44 C> (DEFAULTS TO 1 IF NISKIP=0)
45 C> @param NJSKIP - INTEGER SKIP NUMBER BETWEEN GRID J-POINTS
46 C> (DEFAULTS TO NPS IF NJSKIP=0)
47 C> @param JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
48 C> (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
49 C> @param TRUE - REAL LATITUDE AT WHICH PS GRID IS TRUE (USUALLY 60.)
50 C> @param XMESH - REAL GRID LENGTH AT TRUE LATITUDE (M)
51 C> @param ORIENT - REAL LONGITUDE AT BOTTOM OF NORTHERN PS GRID
52 C> (SOUTHERN PS GRID WILL HAVE OPPOSITE ORIENTATION.)
53 C> @param GRIDUI - REAL (*) INPUT GRID U-WINDS
54 C> @param GRIDVI - REAL (*) INPUT GRID V-WINDS
55 C> @param LUV - LOGICAL FLAG WHETHER TO RETURN WINDS
56 C> @param LDZ - LOGICAL FLAG WHETHER TO RETURN DIVERGENCE AND VORTICITY
57 C> @param LPS - LOGICAL FLAG WHETHER TO RETURN POTENTIAL AND STREAMFCN
58 C> @param UN - REAL (*) NORTHERN PS U-WINDS IF LUV
59 C> @param VN - REAL (*) NORTHERN PS V-WINDS IF LUV
60 C> @param US - REAL (*) SOUTHERN PS U-WINDS IF LUV
61 C> @param VS - REAL (*) SOUTHERN PS V-WINDS IF LUV
62 C> @param DN - REAL (*) NORTHERN DIVERGENCES IF LDZ
63 C> @param ZN - REAL (*) NORTHERN VORTICITIES IF LDZ
64 C> @param DS - REAL (*) SOUTHERN DIVERGENCES IF LDZ
65 C> @param ZS - REAL (*) SOUTHERN VORTICITIES IF LDZ
66 C> @param PN - REAL (*) NORTHERN POTENTIALS IF LPS
67 C> @param SN - REAL (*) NORTHERN STREAMFCNS IF LPS
68 C> @param PS - REAL (*) SOUTHERN POTENTIALS IF LPS
69 C> @param SS - REAL (*) SOUTHERN STREAMFCNS IF LPS
70 C>
71 C> SUBPROGRAMS CALLED:
72 C> - SPWGET GET WAVE-SPACE CONSTANTS
73 C> - SPLAPLAC COMPUTE LAPLACIAN IN SPECTRAL SPACE
74 C> - SPTRANV PERFORM A VECTOR SPHERICAL TRANSFORM
75 C> - SPTGPS TRANSFORM SPECTRAL SCALAR TO POLAR STEREO.
76 C> - SPTGPSV TRANSFORM SPECTRAL VECTOR TO POLAR STEREO.
77 C> - NCPUS GETS ENVIRONMENT NUMBER OF CPUS
78 C>
79 C> REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
80 C> DIMENSION |LINEAR |QUADRATIC
81 C> ----------------------- |--------- |-------------
82 C> IMAX |2*MAXWV+2 |3*MAXWV/2*2+2
83 C> JMAX (IDRT=4,IROMB=0) |1*MAXWV+1 |3*MAXWV/2+1
84 C> JMAX (IDRT=4,IROMB=1) |2*MAXWV+1 |5*MAXWV/2+1
85 C> JMAX (IDRT=0,IROMB=0) |2*MAXWV+3 |3*MAXWV/2*2+3
86 C> JMAX (IDRT=0,IROMB=1) |4*MAXWV+3 |5*MAXWV/2*2+3
87 C> JMAX (IDRT=256,IROMB=0) |2*MAXWV+1 |3*MAXWV/2*2+1
88 C> JMAX (IDRT=256,IROMB=1) |4*MAXWV+1 |5*MAXWV/2*2+1
89  SUBROUTINE sptrunsv(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,KMAX,NPS,
90  & IPRIME,ISKIPI,JSKIPI,KSKIPI,KGSKIP,
91  & NISKIP,NJSKIP,JCPU,TRUE,XMESH,ORIENT,
92  & GRIDUI,GRIDVI,
93  & LUV,UN,VN,US,VS,LDZ,DN,ZN,DS,ZS,
94  & LPS,PN,SN,PS,SS)
95  LOGICAL LUV,LDZ,LPS
96  REAL GRIDUI(*),GRIDVI(*)
97  REAL UN(*),VN(*),US(*),VS(*),DN(*),ZN(*),DS(*),ZS(*)
98  REAL PN(*),SN(*),PS(*),SS(*)
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)
105 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106 C 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)
120 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
121 C TRANSFORM WAVE TO OUTPUT WINDS
122  IF(luv) THEN
123  CALL sptgpsv(iromb,maxwv,kmax,nps,mdim,kgskip,niskip,njskip,
124  & true,xmesh,orient,wd,wz,un,vn,us,vs)
125  ENDIF
126 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
127 C TRANSFORM WAVE TO OUTPUT DIVERGENCE AND VORTICITY
128  IF(ldz) THEN
129  CALL sptgps(iromb,maxwv,kmax,nps,mdim,kgskip,niskip,njskip,
130  & true,xmesh,orient,wd,dn,ds)
131  CALL sptgps(iromb,maxwv,kmax,nps,mdim,kgskip,niskip,njskip,
132  & true,xmesh,orient,wz,zn,zs)
133  ENDIF
134 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
135 C TRANSFORM WAVE TO OUTPUT POTENTIAL AND STREAMFUNCTION
136  IF(lps) THEN
137  CALL spwget(iromb,maxwv,eps,epstop,enn1,elonn1,eon,eontop)
138 C$OMP PARALLEL DO
139  DO k=1,kmax
140  CALL splaplac(iromb,maxwv,enn1,wd(1,k),wd(1,k),-1)
141  CALL splaplac(iromb,maxwv,enn1,wz(1,k),wz(1,k),-1)
142  wd(1:2,k)=0.
143  wz(1:2,k)=0.
144  ENDDO
145  CALL sptgps(iromb,maxwv,kmax,nps,mdim,kgskip,niskip,njskip,
146  & true,xmesh,orient,wd,pn,ps)
147  CALL sptgps(iromb,maxwv,kmax,nps,mdim,kgskip,niskip,njskip,
148  & true,xmesh,orient,wz,sn,ss)
149  ENDIF
150 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
151  END
spwget
subroutine spwget(IROMB, MAXWV, EPS, EPSTOP, ENN1, ELONN1, EON, EONTOP)
This subprogram gets wave-space constants.
Definition: spwget.f:22
sptrunsv
subroutine sptrunsv(IROMB, MAXWV, IDRTI, IMAXI, JMAXI, KMAX, NPS, IPRIME, ISKIPI, JSKIPI, KSKIPI, KGSKIP, NISKIP, NJSKIP, JCPU, TRUE, XMESH, ORIENT, GRIDUI, GRIDVI, LUV, UN, VN, US, VS, LDZ, DN, ZN, DS, ZS, LPS, PN, SN, PS, SS)
THIS SUBPROGRAM SPECTRALLY TRUNCATES VECTOR FIELDS ON A GLOBAL CYLINDRICAL GRID, RETURNING THE FIELDS...
Definition: sptrunsv.f:95
sptgpsv
subroutine sptgpsv(IROMB, MAXWV, KMAX, NPS, KWSKIP, KGSKIP, NISKIP, NJSKIP, TRUE, XMESH, ORIENT, WAVED, WAVEZ, UN, VN, US, VS)
This subprogram performs a spherical transform from spectral coefficients of divergences and curls to...
Definition: sptgpsv.f:81
splaplac
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:22
sptgps
subroutine sptgps(IROMB, MAXWV, KMAX, NPS, KWSKIP, KGSKIP, NISKIP, NJSKIP, TRUE, XMESH, ORIENT, WAVE, GN, GS)
This subprogram performs a spherical transform from spectral coefficients of scalar quantities to sca...
Definition: sptgps.f:75
ncpus
function ncpus()
Set number of cpus.
Definition: ncpus.F:21
sptranv
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:85