      SUBROUTINE SUMSHS (FLN,AP,QLN,N,ihem)
C$$$  SUBPROGRAM DOCUMENTATION BLOCK
C                .      .    .                                       .
C SUBPROGRAM:    SUMSHS      PRODUCES SCALAR FOURIER COEFFICIENTS.
C   PRGMMR: JOSEPH SELA      ORG: W/NMC23    DATE: 88-04-04
C
C ABSTRACT: USES SPHERICAL HARMONICS OF A SCALAR TO PRODUCE THE
C   FOURIER COEFFICIENTS OF THE SCALAR ON THE NORTHERN
C   OR SOUTHERN HEMISPHERE LATITUDE CIRCLES FOR WHICH
C   THE INPUT LEGENDRE FUNCTIONS APPLY.
C
C PROGRAM HISTORY LOG:
C   88-04-04  JOSEPH SELA
c   90-05-23  Hua-Lu Pan
C
C USAGE:    CALL SUMSHS (FLN, AP, QLN, N, ihem)
C   INPUT ARGUMENT LIST:
C     FLN      - ARRAY OF SPHERICAL HARMONICS.
C     QLN      - ARRAY OF ASSOCIATED LEGENDRE FUNCTIONS.
C     N        - NUMBER OF FIELDS IN FLN AND AP ARRAYS.
c     ihem     - +1 for northern hemisphere -1 for southern
C
C   OUTPUT ARGUMENT LIST:
C     AP       - ARRAY OF FOURIER REPRESENTATIONS OF FIELDS ON
C                NORTHERN OR SOUTHERN HEMISPHERE LATITUDE CIRCLES.
C
C  NOTE:  parameter IMXFRM must be greater than or equal to 
C            254 for the T126 resolution
C
C ATTRIBUTES:
C   LANGUAGE: standard FORTRAN 
C   MACHINE:  
C
C$$$
      SAVE
Chou  including more parameters in order to remove the hardwiring of
Chou  spectral coefficients
      INCLUDE "parmanl"
Chou

      DIMENSION AP( 720 ,N),
     1 QLN( NCOEF ), FLN( NCOEF ,N)
      dimension       S( NCOEF ), SEV( JCAP12 ), SOD( JCAP12 )
CC
      NPAIR = ( JCAP1 -3)/2
cmic$ do all private(s,sev,sod) autoscope
      DO 2 K=1,N
      DO 100 I=1, NCOEF
      S(I) = QLN(I) * FLN(I,K)
  100 CONTINUE
      DO 200 I=1, JCAP12
      SEV(I) = S(I)
  200 CONTINUE
      LEN =  JCAP12  - 2
      DO 300 I=1,LEN
      SOD(I) = S(I+ JCAP12 )
  300 CONTINUE
      SOD( JCAP12 -1) = 0.0 E 0
      SOD( JCAP12   ) = 0.0 E 0
      IPLUS =  JCAP12 *2 - 2
      LEN   =  JCAP12  - 4
CC
      DO 600 J=1,NPAIR
      DO 400 I=1,LEN
      SEV(I) = SEV(I) + S(I+IPLUS)
  400 CONTINUE
      IPLUS = IPLUS + LEN
      LEN = LEN - 2
CC
      DO 500 I=1,LEN
      SOD(I) = SOD(I) + S(I+IPLUS)
  500 CONTINUE
      IPLUS = IPLUS + LEN
      LEN = LEN - 2
  600 CONTINUE
CC
      DO 700 I=1,LEN
      SEV(I) = SEV(I) + S(I+IPLUS)
  700 CONTINUE
CC
      DO 800 I=1, JCAP12
      AP(I      ,K) = SEV(I) + ihem * SOD(I)
  800 CONTINUE
    2 CONTINUE
      RETURN
      END
