NCEPLIBS-sp  2.3.3
sptrunl.f
Go to the documentation of this file.
1 C> @file
2 C>
3 C> Spectrally truncate to laplacian
4 C> @author IREDELL @date 96-02-29
5 
6 C> THIS SUBPROGRAM SPECTRALLY TRUNCATES SCALAR FIELDS
7 C> ON A GLOBAL CYLINDRICAL GRID, RETURNING THEIR LAPLACIAN
8 C> OR INVERSE TO A POSSIBLY DIFFERENT GLOBAL CYLINDRICAL GRID.
9 C> THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
10 C> EITHER 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> OVER ZONAL WAVENUMBER TO ENSURE REPRODUCIBILITY.
15 C> TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
16 C> SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
17 C>
18 C> PROGRAM HISTORY LOG:
19 C> - 96-02-29 IREDELL
20 C> - 1998-12-15 IREDELL OPENMP DIRECTIVES INSERTED
21 C>
22 C> @param IROMB - INTEGER SPECTRAL DOMAIN SHAPE
23 C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
24 C> @param MAXWV - INTEGER SPECTRAL TRUNCATION
25 C> @param IDRTI - INTEGER INPUT GRID IDENTIFIER
26 C> (IDRTI=4 FOR GAUSSIAN GRID,
27 C> IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
28 C> IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
29 C> @param IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
30 C> @param JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
31 C> @param IDRTO - INTEGER OUTPUT GRID IDENTIFIER
32 C> (IDRTO=4 FOR GAUSSIAN GRID,
33 C> IDRTO=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
34 C> IDRTO=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
35 C> @param IMAXO - INTEGER EVEN NUMBER OF OUTPUT LONGITUDES.
36 C> @param JMAXO - INTEGER NUMBER OF OUTPUT LATITUDES.
37 C> @param KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
38 C> @param IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
39 C> (DEFAULTS TO 1 IF IPRIME=0)
40 C> (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
41 C> @param ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
42 C> (DEFAULTS TO 1 IF ISKIPI=0)
43 C> @param JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
44 C> (DEFAULTS TO -IMAXI IF JSKIPI=0)
45 C> @param KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
46 C> (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
47 C> @param ISKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LONGITUDES
48 C> (DEFAULTS TO 1 IF ISKIPO=0)
49 C> @param JSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LATITUDES FROM SOUTH
50 C> (DEFAULTS TO -IMAXO IF JSKIPO=0)
51 C> @param KSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT GRID FIELDS
52 C> (DEFAULTS TO IMAXO*JMAXO IF KSKIPO=0)
53 C> @param JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
54 C> (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
55 C> @param IDIR - INTEGER FLAG
56 C> IDIR > 0 TO TAKE LAPLACIAN
57 C> IDIR < 0 TO TAKE INVERSE LAPLACIAN
58 C> @param GRIDI - REAL (*) INPUT GRID FIELDS
59 C> @param GRIDO - REAL (*) OUTPUT GRID FIELDS
60 C> (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
61 C>
62 C> SUBPROGRAMS CALLED:
63 C> - SPWGET GET WAVE-SPACE CONSTANTS
64 C> - SPLAPLAC COMPUTE LAPLACIAN IN SPECTRAL SPACE
65 C> - SPTRAN PERFORM A SCALAR SPHERICAL TRANSFORM
66 C> - NCPUS GETS ENVIRONMENT NUMBER OF CPUS
67 C>
68 C> REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
69 C> DIMENSION |LINEAR |QUADRATIC
70 C> ----------------------- |--------- |-------------
71 C> IMAX |2*MAXWV+2 |3*MAXWV/2*2+2
72 C> JMAX (IDRT=4,IROMB=0) |1*MAXWV+1 |3*MAXWV/2+1
73 C> JMAX (IDRT=4,IROMB=1) |2*MAXWV+1 |5*MAXWV/2+1
74 C> JMAX (IDRT=0,IROMB=0) |2*MAXWV+3 |3*MAXWV/2*2+3
75 C> JMAX (IDRT=0,IROMB=1) |4*MAXWV+3 |5*MAXWV/2*2+3
76 C> JMAX (IDRT=256,IROMB=0) |2*MAXWV+1 |3*MAXWV/2*2+1
77 C> JMAX (IDRT=256,IROMB=1) |4*MAXWV+1 |5*MAXWV/2*2+1
78  SUBROUTINE sptrunl(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,
79  & IDRTO,IMAXO,JMAXO,KMAX,
80  & IPRIME,ISKIPI,JSKIPI,KSKIPI,
81  & ISKIPO,JSKIPO,KSKIPO,JCPU,IDIR,GRIDI,GRIDO)
82 
83  REAL GRIDI(*),GRIDO(*)
84  REAL EPS((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EPSTOP(MAXWV+1)
85  REAL ENN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
86  REAL ELONN1((MAXWV+1)*((IROMB+1)*MAXWV+2)/2)
87  REAL EON((MAXWV+1)*((IROMB+1)*MAXWV+2)/2),EONTOP(MAXWV+1)
88  REAL W((MAXWV+1)*((IROMB+1)*MAXWV+2)/2*2+1,KMAX)
89 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
90 C TRANSFORM INPUT GRID TO WAVE
91  jc=jcpu
92  IF(jc.EQ.0) jc=ncpus()
93  mx=(maxwv+1)*((iromb+1)*maxwv+2)/2
94  mdim=2*mx+1
95  jn=-jskipi
96  IF(jn.EQ.0) jn=imaxi
97  js=-jn
98  inp=(jmaxi-1)*max(0,-jn)+1
99  isp=(jmaxi-1)*max(0,-js)+1
100  CALL sptran(iromb,maxwv,idrti,imaxi,jmaxi,kmax,
101  & iprime,iskipi,jn,js,mdim,kskipi,0,0,jc,
102  & w,gridi(inp),gridi(isp),-1)
103 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104 C TAKE LAPLACIAN AND TRANSFORM WAVE TO OUTPUT GRID
105  CALL spwget(iromb,maxwv,eps,epstop,enn1,elonn1,eon,eontop)
106 C$OMP PARALLEL DO
107  DO k=1,kmax
108  CALL splaplac(iromb,maxwv,enn1,w(1,k),w(1,k),idir)
109  w(1:2,k)=0.
110  ENDDO
111  CALL sptran(iromb,maxwv,idrto,imaxo,jmaxo,kmax,
112  & 0,iskipo,jn,js,mdim,kskipo,0,0,jc,
113  & w,grido(inp),grido(isp),1)
114 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
115  END
spwget
subroutine spwget(IROMB, MAXWV, EPS, EPSTOP, ENN1, ELONN1, EON, EONTOP)
This subprogram gets wave-space constants.
Definition: spwget.f:22
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
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
sptrunl
subroutine sptrunl(IROMB, MAXWV, IDRTI, IMAXI, JMAXI, IDRTO, IMAXO, JMAXO, KMAX, IPRIME, ISKIPI, JSKIPI, KSKIPI, ISKIPO, JSKIPO, KSKIPO, JCPU, IDIR, GRIDI, GRIDO)
THIS SUBPROGRAM SPECTRALLY TRUNCATES SCALAR FIELDS ON A GLOBAL CYLINDRICAL GRID, RETURNING THEIR LAPL...
Definition: sptrunl.f:82