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