      SUBROUTINE QDTFPC2(Q,D,P,C,RNS2LA,LA,ILEV,KASE)
C
C     * DEC 10/97 - B.DENIS.  OPTIMIZED BY EXPLICITLY SETTING
C     *                       (0,0) COEFFICIENT TO ZERO FOR KASE=-1,
C     *                       OUTSIDE OF "K-LOOP", SO THAT "IF"
C     *                       CONDITION CAN BE ELIMINATED. 
C     * MAY 23/94 - M.LAZARE. OPTIMIZED BY USING PRE-CALCULATED
C     *                       VALUE OF N*(N+1).
C 
C     * APR 11/79 - J.D.HENDERSON. ORIGINAL VERSION QDTFPC.
C
C     * CONVERTS BETWEEN (P,C) AND (Q,D) BASED ON VALUE OF KASE.
C 
C     * Q(LA,ILEV) = SPECTRAL VORTICITY 
C     * D(LA,ILEV) = SPECTRAL DIVERGENCE
C     * P(LA,ILEV) = SPECTRAL STREAMFUNCTION
C     * C(LA,ILEV) = SPECTRAL VELOCITY POTENTIAL
C 
C     * KASE = +1 CONVERTS P,C TO Q,D.
C     * KASE = -1 CONVERTS Q,D TO P,C.
C 
C     * LEVEL 2,Q,D,P,C 

      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)

      REAL RNS2LA(LA)
      COMPLEX Q(LA,ILEV),D(LA,ILEV),P(LA,ILEV),C(LA,ILEV) 
C-------------------------------------------------------------------
C     * KASE = +1 CONVERTS P,C TO Q,D.
C 
      IF(KASE.LT.0) GO TO 310 
      DO 290 L=1,ILEV 
      DO 290 K=1,LA
        Q(K,L)=-1.*RNS2LA(K)*P(K,L) 
        D(K,L)=-1.*RNS2LA(K)*C(K,L) 
  290 CONTINUE
      RETURN
C 
C     * KASE = -1 CONVERTS Q,D TO P,C.
C 
  310 CONTINUE
      DO 390 L=1,ILEV 
        P(1,L)=0.
        C(1,L)=0.
        DO 380 K=2,LA
          RFNS1 =1./RNS2LA(K)
          P(K,L)=-RFNS1*Q(K,L)
          C(K,L)=-RFNS1*D(K,L)
  380   CONTINUE
  390 CONTINUE
C 
      RETURN
      END
