NCEPLIBS-sp 2.4.0
sptrunl.f
Go to the documentation of this file.
1C> @file
2C>
3C> Spectrally truncate to laplacian
4C> @author IREDELL @date 96-02-29
5
6C> THIS SUBPROGRAM SPECTRALLY TRUNCATES SCALAR FIELDS
7C> ON A GLOBAL CYLINDRICAL GRID, RETURNING THEIR LAPLACIAN
8C> OR INVERSE TO A POSSIBLY DIFFERENT GLOBAL CYLINDRICAL GRID.
9C> THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
10C> EITHER GRID-SPACE CAN BE EITHER AN EQUALLY-SPACED GRID
11C> (WITH OR WITHOUT POLE POINTS) OR A GAUSSIAN GRID.
12C> THE GRID FIELDS MAY HAVE GENERAL INDEXING.
13C> THE TRANSFORMS ARE ALL MULTIPROCESSED.
14C> OVER ZONAL WAVENUMBER TO ENSURE REPRODUCIBILITY.
15C> TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
16C> SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
17C>
18C> PROGRAM HISTORY LOG:
19C> - 96-02-29 IREDELL
20C> - 1998-12-15 IREDELL OPENMP DIRECTIVES INSERTED
21C>
22C> @param IROMB - INTEGER SPECTRAL DOMAIN SHAPE
23C> (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
24C> @param MAXWV - INTEGER SPECTRAL TRUNCATION
25C> @param IDRTI - INTEGER INPUT GRID IDENTIFIER
26C> (IDRTI=4 FOR GAUSSIAN GRID,
27C> IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
28C> IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
29C> @param IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
30C> @param JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
31C> @param IDRTO - INTEGER OUTPUT GRID IDENTIFIER
32C> (IDRTO=4 FOR GAUSSIAN GRID,
33C> IDRTO=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
34C> IDRTO=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
35C> @param IMAXO - INTEGER EVEN NUMBER OF OUTPUT LONGITUDES.
36C> @param JMAXO - INTEGER NUMBER OF OUTPUT LATITUDES.
37C> @param KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
38C> @param IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
39C> (DEFAULTS TO 1 IF IPRIME=0)
40C> (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
41C> @param ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
42C> (DEFAULTS TO 1 IF ISKIPI=0)
43C> @param JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
44C> (DEFAULTS TO -IMAXI IF JSKIPI=0)
45C> @param KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
46C> (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
47C> @param ISKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LONGITUDES
48C> (DEFAULTS TO 1 IF ISKIPO=0)
49C> @param JSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LATITUDES FROM SOUTH
50C> (DEFAULTS TO -IMAXO IF JSKIPO=0)
51C> @param KSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT GRID FIELDS
52C> (DEFAULTS TO IMAXO*JMAXO IF KSKIPO=0)
53C> @param JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
54C> (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
55C> @param IDIR - INTEGER FLAG
56C> IDIR > 0 TO TAKE LAPLACIAN
57C> IDIR < 0 TO TAKE INVERSE LAPLACIAN
58C> @param GRIDI - REAL (*) INPUT GRID FIELDS
59C> @param GRIDO - REAL (*) OUTPUT GRID FIELDS
60C> (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
61C>
62C> SUBPROGRAMS CALLED:
63C> - SPWGET GET WAVE-SPACE CONSTANTS
64C> - SPLAPLAC COMPUTE LAPLACIAN IN SPECTRAL SPACE
65C> - SPTRAN PERFORM A SCALAR SPHERICAL TRANSFORM
66C> - NCPUS GETS ENVIRONMENT NUMBER OF CPUS
67C>
68C> REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
69C> DIMENSION |LINEAR |QUADRATIC
70C> ----------------------- |--------- |-------------
71C> IMAX |2*MAXWV+2 |3*MAXWV/2*2+2
72C> JMAX (IDRT=4,IROMB=0) |1*MAXWV+1 |3*MAXWV/2+1
73C> JMAX (IDRT=4,IROMB=1) |2*MAXWV+1 |5*MAXWV/2+1
74C> JMAX (IDRT=0,IROMB=0) |2*MAXWV+3 |3*MAXWV/2*2+3
75C> JMAX (IDRT=0,IROMB=1) |4*MAXWV+3 |5*MAXWV/2*2+3
76C> JMAX (IDRT=256,IROMB=0) |2*MAXWV+1 |3*MAXWV/2*2+1
77C> 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)
89C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
90C 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)
103C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104C TAKE LAPLACIAN AND TRANSFORM WAVE TO OUTPUT GRID
105 CALL spwget(iromb,maxwv,eps,epstop,enn1,elonn1,eon,eontop)
106C$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)
114C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
115 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 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:88
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
subroutine spwget(IROMB, MAXWV, EPS, EPSTOP, ENN1, ELONN1, EON, EONTOP)
This subprogram gets wave-space constants.
Definition: spwget.f:18