      SUBROUTINE PLN2H (QLNT, QLNV, COLRAD)
C$$$  SUBPROGRAM DOCUMENTATION BLOCK
C                .      .    .                                       .
C SUBPROGRAM:    PLN2H       EVALUATES ASSOCIATED LEGENDRE FUNCTIONS.
C   PRGMMR: JOSEPH SELA      ORG: W/NMC23    DATE: 88-10-25
C
C ABSTRACT: EVALUATES THE REQUIRED VALUES OF THE NORMALIZED
C   ASSOCIATED LEGENDRE FUNCTION AT A PRESCRIBED COLATITUDE.
C   A STANDARD RECURSION RELATION IS USED WITH REAL ARITHMETIC.
C
C PROGRAM HISTORY LOG:
C   88-10-25  JOSEPH SELA
C
C USAGE:    CALL PLN2H (QLNT, QLNV, COLRAD)
C   INPUT ARGUMENT LIST:
C     COLRAD   - COLATITUDE IN RADIANS FOR WHICH
C                THE ASSOCIATED LEGENDRE FUNCTIONS ARE TO BE
C                COMPUTED.
C
C   OUTPUT ARGUMENT LIST:
C     QLNT     - DOUBLED SCALAR TRIANGLE OF
C                ASSOCIATED LEGENDRE FUNCTIONS.
C     QLNV     - DOUBLED VECTOR TRIANGLE OF
C                ASSOCIATED LEGENDRE FUNCTIONS.
C
C ATTRIBUTES:
C   LANGUAGE: standard FORTRAN 
C   MACHINE:  CRAY
C
C$$$
           SAVE
CC
Chou
Chou  including more parameters in order to remove the hardwiring of 
Chou  spectral coefficients
      INCLUDE "parmanl"
Chou
      DIMENSION         QLNT( NCOEF )
      DIMENSION         QLNV( NCOEF2 )
      DIMENSION         DEPS( NCOEF2 )
      REAL              DEPS
      DIMENSION        RDEPS( NCOEF2 )
      REAL             RDEPS
      dimension            X( JCAP1 )
      REAL                 X
      DIMENSION           DX( JCAP12 )
      REAL                DX
      DIMENSION            Y( JCAP1 )
      REAL                 Y
      dimension         DPLN( NCOEF2 )
      REAL              DPLN
      REAL              COLR
      REAL            SINLAT
      REAL              COS2
      REAL              PROD
      common /pln2tc/ifir,deps,rdeps,dx,y
CC
      DATA IFIR /0/
      IF  (IFIR .EQ. 1)  GO TO 500
           IFIR = 1
      DO 200 LL=1, JCAP1
             RDEPS(LL) = 0.0
  200 CONTINUE
      LPLUS =  JCAP1
      LEN   =  JCAP1
      DO 240 INDE=2, JCAP+2
      DO 220   LL=1,LEN
             L = LL - 1
             N = L + INDE - 1
             RDEPS(LL+LPLUS) = (N*N - L*L) / (4.0 * N*N - 1.0)
  220 CONTINUE
      LPLUS = LPLUS + LEN
      LEN = LEN - 1
  240 CONTINUE
      DO 260 I= JCAP+2 , NCOEF4
             RDEPS(I) = SQRT(RDEPS(I))
  260 CONTINUE
      DO 300 I=1, NCOEF4
             DEPS(2*I-1) = RDEPS(I)
             DEPS(2*I  ) = RDEPS(I)
  300 CONTINUE
      IBEGIN =  JCAP12  + 1
      DO 320 I=IBEGIN, NCOEF2
             RDEPS(I) = 1.0/DEPS(I)
  320 CONTINUE
      DO 400 LL=1, JCAP1
             X(LL) = LL*2+1
  400 CONTINUE
      DO 420 LL=1, JCAP1
             Y(LL) = X(LL)/(X(LL)-1.)
  420 CONTINUE
      DO 440 LL=1, JCAP1
             X(LL) = SQRT(X(LL))
  440 CONTINUE
      DO 460 LL=1, JCAP1
             DX(2*LL-1) = X(LL)
             DX(2*LL  ) = X(LL)
  460 CONTINUE
  500 CONTINUE
CC
      COLR   = COLRAD
      SINLAT = COS(COLR)
      COS2   = 1.0 - SINLAT * SINLAT
      PROD   = 1.0
      DO 600 LL=1, JCAP1
             X(LL) = 0.5*PROD
CCCC         IF (PROD .LT. 1.0E-75)  PROD=0.0
             PROD = PROD*COS2*Y(LL)
  600 CONTINUE
      DO 620 LL=1, JCAP1
             X(LL) = SQRT(X(LL))
  620 CONTINUE
      DO 640 LL=1, JCAP1
             DPLN(2*LL-1) = X(LL)
             DPLN(2*LL  ) = X(LL)
  640 CONTINUE
      LPLUS =  JCAP12
      DO 700 LL=1, JCAP12
             DPLN(LL+LPLUS) = DX(LL) * SINLAT * dPLN(LL)
  700 CONTINUE
      LP2 = 0
      LP1 =      JCAP12
      LP0 = 2 *  JCAP12
      LEN =      JCAP12  - 2
      DO 740  N=3, JCAP+2
cdir$ ivdep
      DO 720 LL=1,LEN
             DPLN(LL+LP0) = (SINLAT * DPLN(LL+LP1)
     1               - DEPS(LL+LP1) * DPLN(LL+LP2)) * RDEPS(LL+LP0)
  720 CONTINUE
      LP2 = LP1
      LP1 = LP0
      LP0 = LP0 + LEN
      LEN = LEN - 2
  740 CONTINUE
CC
      DO 800 I=1, NCOEF2
             QLNV(I) = DPLN(I)
  800 CONTINUE
CC
      LEN = 2 *  JCAP12  - 2
      DO 820 LL=1,LEN
             QLNT(LL) = QLNV(LL)
  820 CONTINUE
      LPV = 2 *  JCAP12
      LPT = LPV - 2
      LEN =  JCAP12  - 4
      DO 860 N=3, JCAP1
      DO 840 LL=1,LEN
             QLNT(LL+LPT) = QLNV(LL+LPV)
  840 CONTINUE
      LPV = LPV + LEN + 2
      LPT = LPT + LEN
      LEN = LEN - 2
  860 CONTINUE
CC
      RETURN
      END
