c c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . c . . c . copyright (c) 1998 by UCAR . c . . c . University Corporation for Atmospheric Research . c . . c . all rights reserved . c . . c . . c . SPHEREPACK . c . . c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . c c August 2003 c c ... in file shpg.f c c this file contains documentation for subroutines c shpgi and shpg. a test file is in tshpg.f c c ... files which must be loaded with shpg.f c c hrfft.f c c shpgi initializes the arrays wshp and iwshp for subsequent c use in subroutine shpg, which performs the harmonic projection c which is equivalent to a harmonic analysis followed by c harmonic synthesis but faster and with less memory. c (see description of subroutine shpg below). c c subroutine shpgi(nlat,nlon,isym,mtrunc,wshp,lwshp,iwshp, c 1 liwshp,work,lwork,ierror) c c shpgi initializes arrays wshp and iwshp for repeated use c by subroutine shpg .... c c input parameters c c nlat the number of colatitudes on the full sphere including the c poles. for example, nlat = 37 for a five degree grid. c nlat determines the grid increment in colatitude as c pi/(nlat-1). if nlat is odd the equator is located at c grid point i=(nlat+1)/2. if nlat is even the equator is c located half way between points i=nlat/2 and i=nlat/2+1. c nlat must be at least 3. c c nlon the number of distinct londitude points. nlon determines c the grid increment in longitude as 2*pi/nlon. for example c nlon = 72 for a five degree grid. nlon must be greater c than or equal to 4. the efficiency of the computation is c improved when nlon is a product of small prime numbers. c nlon must be at least 4. c c isym currently not used, no equatorial symmetries assumed, c only whole sphere computations. c c mtrunc the highest longitudinal wave number retained in the c projection. It must be less than or equal to c the minimum of nlat-1 and nlon/2. The first wave c number is zero. For example, if wave numbers 0 and c 1 are desired then mtrunc = 1. c c lwshp the dimension of the array wshp as it appears in the c program that calls shpgi. It must be at least c 2*(nlat+1)**2+nlon+log2(nlon) c c liwshp the dimension of the array iwshp as it appears in the c program that calls shpgi. It must be at least c 4*(nlat+1). c c lwork the dimension of the array work as it appears in the c program that calls shpgi. It must be at least c 1.25*(nlat+1)**2+7*nlat+8. c c ************************************************************** c c output parameters c c wshp a single precision array that must be saved for c repeated use by subroutine shpg. c c iwshp an integer array that must be saved for repeated c use by subroutine shpg. c c work a double precision work array that does c not have to be saved. c c ierror = 0 no errors c = 1 error in the specification of nlat c = 2 error in the specification of nlon c = 3 error in the specification of isym c = 4 error in the specification of mtrunc c = 5 error in the specification of lwshp c = 6 error in the specification of liwshp c = 7 error in the specification of lwork c c c c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . c . . c . copyright (c) 1998 by UCAR . c . . c . University Corporation for Atmospheric Research . c . . c . all rights reserved . c . . c . . c . SPHEREPACK3.0 . c . . c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . c c ... file shpg.f c c ... files which must be loaded with shpg.f c c hrfft.f c c shpg computes the harmonic projection, which is c equivalent to a harmonic analysis (forward) followed c by a harmonic synthesis (backward transform). c shpg uses the n**2 projection or complement when appropriate c as well as odd/even factorization and zero truncation on an c on a Gaussian distributed grid as defined in the JCP paper c "Generalized discrete spherical harmonic transforms" c by Paul N. Swarztrauber and William F. Spotz c J. Comp. Phys., 159(2000) pp. 213-230. c c subroutine shpg(nlat,nlon,isym,mtrunc,x,y,idxy, c 1 wshp,lwshp,iwshp,liwshp,work,lwork,ierror) c c shpg projects the array x onto the set of functions represented c by a discrete set of spherical harmonics. c c input parameters c c nlat the number of colatitudes on the full sphere including the c poles. for example, nlat = 37 for a five degree grid. c nlat determines the grid increment in colatitude as c pi/(nlat-1). if nlat is odd the equator is located at c grid point i=(nlat+1)/2. if nlat is even the equator is c located half way between points i=nlat/2 and i=nlat/2+1. c nlat must be at least 3. c c nlon the number of distinct londitude points. nlon determines c the grid increment in longitude as 2*pi/nlon. for example c nlon = 72 for a five degree grid. nlon must be greater c than or equal to 4. the efficiency of the computation is c improved when nlon is a product of small prime numbers. c nlon must be at least 4. c c isym currently not used. c c mtrunc the highest longitudinal wave number retained in the c projection. It must be less than or equal to c the minimum of nlat-1 and nlon/2. The first wave c number is zero. For example, if wave numbers 0 and c 1 are desired then mtrunc = 1. c zero. c c x a two dimensional array that contains the the nlat c by nlon array x(i,j) defined at the colatitude point c theta(i) = (i-1)*pi/(nlat-1) and longitude point phi(j) = c (j-1)*2*pi/nlon. c c idxy the first dimension of the arrays x and y as they c appear in the program that calls shpg. It must be c at least nlat. c c wshp a single precision array that must be saved for c repeated use by subroutine shpg. c c lwshp the dimension of the array wshp as it appears in the c program that calls shpgi. It must be at least c 2*(nlat+1)**2+nlon+log2(nlon) c c iwshp an integer array that must be saved for repeated c use by subroutine shpg. c c c liwshp the dimension of the array iwshp as it appears in the c program that calls shpgi. It must be at least c 4*(nlat+1). c c work a single precision work array that does c not have to be saved. c c lwork the dimension of the array work as it appears in the c program that calls shpg. It must be at least c max(nlat*nlon,4*(nlat+1)). c c ************************************************************** c c output parameters c c y an nlat by nlon single precision array that contains c the projection of x onto the set of functions that c can be represented by the discrete set of spherical c harmonics. The arrays x(i,j) and y(i,j) are located c at colatitude point theta(i) = (i-1)*pi/(nlat-1) and c longitude point phi(j) = (j-1)*2*pi/nlon. c c ierror = 0 no errors c = 1 error in the specification of nlat c = 2 error in the specification of nlon c = 3 error in the specification of isym c = 4 error in the specification of mtrunc c = 5 error in the specification of lwshp c = 6 error in the specification of liwshp c = 7 error in the specification of lwork c