NCEPLIBS-sp  2.5.0
sptranv.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Perform a vector spherical transform.
3 C>
4 C> ### Program History Log
5 C> Date | Programmer | Comments
6 C> -----|------------|---------
7 C> 96-02-29 | IREDELL | Initial.
8 C> 1998-12-15 | IREDELL | Generic fft used, openmp directives inserted
9 C>
10 C> @author IREDELL @date 96-02-29
11 
12 C> This subprogram performs a spherical transform
13 C> between spectral coefficients of divergences and curls
14 C> and vector fields on a global cylindrical grid.
15 C>
16 C> The wave-space can be either triangular or rhomboidal.
17 C>
18 C> The grid-space can be either an equally-spaced grid
19 C> (with or without pole points) or a Gaussian grid.
20 C> the wave and grid fields may have general indexing,
21 C> but each wave field is in sequential 'ibm order',
22 C> i.e. with zonal wavenumber as the slower index.
23 C>
24 C> Transforms are done in latitude pairs for efficiency;
25 C> thus grid arrays for each hemisphere must be passed.
26 C> If so requested, just a subset of the latitude pairs
27 C> may be transformed in each invocation of the subprogram.
28 C>
29 C> The transforms are all multiprocessed over latitude except
30 C> the transform from fourier to spectral is multiprocessed
31 C> over zonal wavenumber to ensure reproducibility.
32 C>
33 C> Transform several fields at a time to improve vectorization.
34 C> Subprogram can be called from a multiprocessing environment.
35 C>
36 C> Minimum grid dimensions for unaliased transforms to spectral:
37 C> DIMENSION |LINEAR |QUADRATIC
38 C> ----------------------- |--------- |-------------
39 C> IMAX |2*MAXWV+2 |3*MAXWV/2*2+2
40 C> JMAX (IDRT=4,IROMB=0) |1*MAXWV+1 |3*MAXWV/2+1
41 C> JMAX (IDRT=4,IROMB=1) |2*MAXWV+1 |5*MAXWV/2+1
42 C> JMAX (IDRT=0,IROMB=0) |2*MAXWV+3 |3*MAXWV/2*2+3
43 C> JMAX (IDRT=0,IROMB=1) |4*MAXWV+3 |5*MAXWV/2*2+3
44 C> JMAX (IDRT=256,IROMB=0) |2*MAXWV+1 |3*MAXWV/2*2+1
45 C> JMAX (IDRT=256,IROMB=1) |4*MAXWV+1 |5*MAXWV/2*2+1
46 C>
47 C> @param IROMB SPECTRAL DOMAIN SHAPE
48 C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
49 C> @param MAXWV SPECTRAL TRUNCATION
50 C> @param IDRT GRID IDENTIFIER
51 C> - IDRT=4 FOR GAUSSIAN GRID,
52 C> - IDRT=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
53 C> - IDRT=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES
54 C> @param IMAX EVEN NUMBER OF LONGITUDES.
55 C> @param JMAX NUMBER OF LATITUDES.
56 C> @param KMAX NUMBER OF FIELDS TO TRANSFORM.
57 C> @param IPRIME LONGITUDE INDEX FOR THE PRIME MERIDIAN.
58 C> (DEFAULTS TO 1 IF IPRIME=0)
59 C> @param ISKIP SKIP NUMBER BETWEEN LONGITUDES
60 C> (DEFAULTS TO 1 IF ISKIP=0)
61 C> @param JNSKIP SKIP NUMBER BETWEEN N.H. LATITUDES FROM NORTH
62 C> (DEFAULTS TO IMAX IF JNSKIP=0)
63 C> @param JSSKIP SKIP NUMBER BETWEEN S.H. LATITUDES FROM SOUTH
64 C> (DEFAULTS TO -IMAX IF JSSKIP=0)
65 C> @param KWSKIP SKIP NUMBER BETWEEN WAVE FIELDS
66 C> (DEFAULTS TO (MAXWV+1)*((IROMB+1)*MAXWV+2) IF KWSKIP=0)
67 C> @param KGSKIP SKIP NUMBER BETWEEN GRID FIELDS
68 C> (DEFAULTS TO IMAX*JMAX IF KGSKIP=0)
69 C> @param JBEG LATITUDE INDEX (FROM POLE) TO BEGIN TRANSFORM
70 C> - DEFAULTS TO 1 IF JBEG=0
71 C> - IF JBEG=0 AND IDIR<0, WAVE IS ZEROED BEFORE TRANSFORM
72 C> @param JEND LATITUDE INDEX (FROM POLE) TO END TRANSFORM
73 C> (DEFAULTS TO (JMAX+1)/2 IF JEND=0)
74 C> @param JCPU NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
75 C> @param[out] WAVED (*) WAVE DIVERGENCE FIELDS IF IDIR>0
76 C> [WAVED=(D(GRIDU)/DLAM+D(CLAT*GRIDV)/DPHI)/(CLAT*RERTH)]
77 C> @param[out] WAVEZ (*) WAVE VORTICITY FIELDS IF IDIR>0
78 C> [WAVEZ=(D(GRIDV)/DLAM-D(CLAT*GRIDU)/DPHI)/(CLAT*RERTH)]
79 C> @param[out] GRIDUN N.H. GRID U-WINDS (STARTING AT JBEG) IF IDIR<0
80 C> @param[out] GRIDUS S.H. GRID U-WINDS (STARTING AT JBEG) IF IDIR<0
81 C> @param[out] GRIDVN N.H. GRID V-WINDS (STARTING AT JBEG) IF IDIR<0
82 C> @param[out] GRIDVS S.H. GRID V-WINDS (STARTING AT JBEG) IF IDIR<0
83 C> @param IDIR TRANSFORM FLAG
84 C> - IDIR>0 FOR WAVE TO GRID,
85 C> - IDIR<0 FOR GRID TO WAVE
86 C>
87  SUBROUTINE sptranv(IROMB,MAXWV,IDRT,IMAX,JMAX,KMAX,
88  & IPRIME,ISKIP,JNSKIP,JSSKIP,KWSKIP,KGSKIP,
89  & JBEG,JEND,JCPU,
90  & WAVED,WAVEZ,GRIDUN,GRIDUS,GRIDVN,GRIDVS,IDIR)
91 
92  REAL WAVED(*),WAVEZ(*),GRIDUN(*),GRIDUS(*),GRIDVN(*),GRIDVS(*)
93 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
94  MX=(maxwv+1)*((iromb+1)*maxwv+2)/2
95  ip=iprime
96  is=iskip
97  jn=jnskip
98  js=jsskip
99  kw=kwskip
100  kg=kgskip
101  jb=jbeg
102  je=jend
103  jc=jcpu
104  IF(ip.EQ.0) ip=1
105  IF(is.EQ.0) is=1
106  IF(jn.EQ.0) jn=imax
107  IF(js.EQ.0) js=-jn
108  IF(kw.EQ.0) kw=2*mx
109  IF(kg.EQ.0) kg=imax*jmax
110  IF(jb.EQ.0) jb=1
111  IF(je.EQ.0) je=(jmax+1)/2
112  IF(jc.EQ.0) jc=ncpus()
113 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
114  IF(idir.LT.0.AND.jbeg.EQ.0) THEN
115  DO k=1,kmax
116  kws=(k-1)*kw
117  waved(kws+1:kws+2*mx)=0
118  wavez(kws+1:kws+2*mx)=0
119  ENDDO
120  ENDIF
121 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
122  CALL sptranfv(iromb,maxwv,idrt,imax,jmax,kmax,
123  & ip,is,jn,js,kw,kg,jb,je,jc,
124  & waved,wavez,gridun,gridus,gridvn,gridvs,idir)
125 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
126  END
function ncpus()
Set number of CPUs - the number of processors over which to parallelize.
Definition: ncpus.F:24
subroutine sptranfv(IROMB, MAXWV, IDRT, IMAX, JMAX, KMAX, IP, IS, JN, JS, KW, KG, JB, JE, JC, WAVED, WAVEZ, GRIDUN, GRIDUS, GRIDVN, GRIDVS, IDIR)
This subprogram performs a spherical transform between spectral coefficients of divergences and curls...
Definition: sptranfv.f:83
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