      SUBROUTINE HORIZ2(DOT,NAS,PER,G,JG,Y,PERCUT,L,NFG,DK,TK)
      COMMON/NMODF/NFILES
CJPB  COMPLEX*8 DOT(NAS),Y(JG)
      COMPLEX   DOT(NAS),Y(JG)
C     NAS=VECTOR SIZE OF SYM. OR  ASY. TENDENCIES STORED IN DOT
C     JG=NUNBER OF GRAVITY MODES. JG=JCAP FOR L=0 SYM AND ASY CASES
C     FOR L.NE.0 JG=JCAP2 FOR SYM,JG=JCAP FOR ASY.
C     PER STORES PERIODS OF GRAVITY MODES,G STORES EIGENVECTORS
      DIMENSION PER(JG),G(JG,NAS)
      READ(NFG) PER,G
      DIF=DK/( 6370000. **4)
      JT=0
      JC=0
      JD=0
      G1=0.
      G2=0.
      N=L+ 17
      I=0
100   I=I+1
      PERIOD=ABS(PER(I))
      IF(PERIOD-PERCUT)10,10,200
10    JC=JC+1
      Y(I)=(0.,0.)
      N=N-1
      DIFCUT=DIF*N*N*(N+1.)*(N+1.)  +  1.E-6
      DIFCUT=0.5/DIFCUT
      IF(DIFCUT-PERIOD)100,20,20
20    JD=JD+1
C***  IF ARRIVED HERE,ADJUST......
      JT=JT+1
      DO 30 J=1,NAS
      Y(I)=Y(I)+CMPLX(G(I,J)*REAL(DOT(J)),G(I,J)*AIMAG(DOT(J)))
30    CONTINUE
      G1=G1+REAL(Y(I))*REAL(Y(I)) + AIMAG(Y(I))*AIMAG(Y(I))
      Y(I)=CMPLX(PER(I)*AIMAG(Y(I)),-PER(I)*REAL(Y(I)))
      G2=G2+REAL(Y(I))*REAL(Y(I)) + AIMAG(Y(I))*AIMAG(Y(I))
C
      IF(I-JG)100,300,300
C
200   I=I-1
300   CONTINUE
      DO 40 J=1,NAS
40    DOT(J)=(0.,0.)
      IF(I.EQ.0)RETURN
      G1=SQRT(G1)
      G2=SQRT(G2)
      DO 50 J=1,NAS
      DO 50 K=1,I
      DOT(J)=DOT(J)+CMPLX(G(K,J)*REAL(Y(K)),G(K,J)*AIMAG(Y(K)))
50    CONTINUE
C     IF(NAS.EQ. 26 )WRITE(6,500)L,JT,G1,G2,JC,JD,I
C     IF(NAS.EQ. 25 )WRITE(6,501)L,JT,G1,G2,JC,JD,I
500   FORMAT(1H ,'SYM,L=',I2,2X,'TOT ADJUSTED=',I3,2X,'GDOT=',E12.4
     1,2X,'DELTA(G)=',E12.4,2X,'JC=',I3,2X,'JD=',I3,2X,'I=',I3)
501   FORMAT(1H ,'ASY,L=',I2,2X,'TOT ADJUSTED=',I3,2X,'GDOT=',E12.4
     1,2X,'DELTA(G)=',E12.4,2X,'JC=',I3,2X,'JD=',I3,2X,'I=',I3)
      RETURN
      END
