      SUBROUTINE GWAQD2(Q,D,LSR,LM,UGG,VGG,ILG1,ILAT,SL,WOSSL,
     1               ALP,DALP,EPSI,WRKS,WRKL) 
C 
C     * JUL 14/92 - E. CHAN (ADD REAL*8 DECLARATIONS)
C     * JUL 18/79 - J.D.HENDERSON 
C     * CONVERTS GLOBAL GAUSSIAN GRIDS OF U,V IN UGG,VGG(ILG1,ILAT) 
C     * TO SPECTRAL COEFF OF VORTICITY (Q) AND DIVERGENCE (D).
C     * NOTE THAT U,V ARE ACTUALLY U,V*COS(LAT)/(EARTH RADIUS). 
C 
C     * LSR CONTAINS SPECTRAL ROW LENGTH INFO.
C     * SL(ILAT) CONTAINS SIN(LAT) (S TO N).
C     * WOSSL(ILAT) CONTAINS (GAUSSIAN WEIGHTS)/(SIN(LAT)**2).
C     * ALP IS A WORK FIELD FOR LEGENDRE POLYNOMIALS. 
C     * DALP IS FOR N-S DERIVATIVES OF ALP. 
C     * EPSI CONTAINS PRECOMPUTED CONSTANTS.
C     * WRKS,WRKL ARE SCM,LCM WORK FIELDS OF LR COMPLEX WORDS.
C     * FFT REQUIRES THAT ILG BE (2**N) OR 3*(2**N).
C 
C     * LEVEL 2,Q,D,UGG,VGG,WRKL
C     * LEVEL 2,ALP,DALP,EPSI 
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      COMPLEX Q(1),D(1),WRKL(1) 
      REAL UGG(ILG1,1),VGG(ILG1,1),WRKS(1)
      REAL*8 ALP(1),DALP(1),EPSI(1),SL(1),WOSSL(1),WEIGHT 
      INTEGER LSR(2,1)
C---------------------------------------------------------------------
      ILG=ILG1-1
      ILGH=ILG/2
C 
C     * INITIALIZE Q,D TO ZERO. 
C 
      NP=LSR(1,LM+1)-1
      CALL SCOF2(Q,NP,1,0)
      CALL SCOF2(D,NP,1,0)
C 
      DO 40 J=1,ILAT
      WEIGHT=WOSSL(J) 
C 
C     * COMPUTE ALP AND DALP. 
C 
      CALL ALPST2(ALP, LSR,LM,SL(J),EPSI) 
      CALL ALPDY2(DALP,ALP, LSR,LM,EPSI)
C 
C     * TERMS DEPENDING ON U. 
C 
      CALL FFWFG2(WRKL,ILGH,UGG(1,J),ILG1,LM-1,ILG,WRKS,1)
      CALL FAST2(Q,LSR,LM,WRKL,DALP, WEIGHT)
      DO 22 M=1,LM
      FMS=FLOAT(M-1)
      WRKL(M)=CMPLX(-FMS* IMAG(WRKL(M)),FMS*REAL(WRKL(M)))
   22 CONTINUE
      CALL FAST2(D,LSR,LM,WRKL, ALP, WEIGHT)
C 
C     * TERMS DEPENDING ON V. 
C 
      CALL FFWFG2(WRKL,ILGH,VGG(1,J),ILG1,LM-1,ILG,WRKS,1)
      CALL FAST2(D,LSR,LM,WRKL,DALP,-WEIGHT)
      DO 24 M=1,LM
      FMS=FLOAT(M-1)
      WRKL(M)=CMPLX(-FMS* IMAG(WRKL(M)),FMS*REAL(WRKL(M)))
   24 CONTINUE
      CALL FAST2(Q,LSR,LM,WRKL, ALP, WEIGHT)
   40 CONTINUE
C 
      RETURN
      END 
