CJPB
      SUBROUTINE HORIZ1(VORD,DIVD,COMD,SDOTR,ADOTR,PER,GC,WORKR,DK,TK,
     1 V,NF,MODS)
CJPB  SUBROUTINE HORIZ1(VORD,DIVD,COMD,SDOT,ADOT,PER,G,WORK,DK,TK,V,
CJPB 1 NF,MODS)
      COMMON/NMODF/NFILES
CJPB  COMPLEX*8 SDOT( 26 ),ADOT( 25 ),WORK( 18 ),
      COMPLEX   SDOT( 26 ),ADOT( 25 ),WORK( 18 ),
     1VORD( 17 , 17 , 7 ),
     2DIVD( 17 , 17 , 7 ),
     2COMD( 17 , 17 , 7 )
      DIMENSION PER( 18 ),G( 18 , 26 )
CJPB
      DIMENSION SDOTR(52),ADOTR(50),WORKR(36)
      DIMENSION SDOTS(52),ADOTS(50),WORKS(36)
      COMPLEX GC(234),GS(234)
      EQUIVALENCE (SDOTS,SDOT),(ADOTS,ADOT),(WORKS,WORK)
      EQUIVALENCE (GS,G)
CJPB
      DATA NS/ 26 /,NA/ 25 /,
     1 JSEV/ 9 /,JSOD/ 8 /
      JEVPOD=JSEV+JSOD
CJPB
      DO 5 I=1,52
5     SDOTS(I)=SDOTR(I)
      DO 6 I=1,50
6     ADOTS(I)=ADOTR(I)
      DO 7 I=1,36
7     WORKS(I)=WORKR(I)
      DO 8 I=1,234
8     GS(I)=GC(I)
CJPB
      DO 2000 MOD=1,MODS
      WRITE(6,100)MOD
100   FORMAT(1H0,'DOING MODE ',I2)
      NFG=NF+MOD
      IF(NFILES.EQ.1)NFG=NF
      DO 1000 LL=1, 17
      K=0
      L=LL-1
      DO 10 I=2, 16 ,2
      K=K+1
      SDOT(K)=VORD(I,LL,MOD)
      ADOT(K+JSEV)=DIVD(I,LL,MOD)
      ADOT(K+JEVPOD) =COMD(I,LL,MOD)
10    CONTINUE
      K=0
      DO 20 I=1, 17 ,2
      K=K+1
      ADOT(K)=VORD(I,LL,MOD)
      SDOT(K+JSOD)=DIVD(I,LL,MOD)
      SDOT(K+JEVPOD) =COMD(I,LL,MOD)
20    CONTINUE
      IF(L.EQ.0) GO TO 500
      CALL HORIZ2(SDOT,NS,PER,G, 18 ,WORK,V,L,NFG,DK,TK)
500   IF(L.GT.0)GO TO 600
      CALL HORIZ2(SDOT,NS,PER,G, 16 ,WORK,V,L,NFG,DK,TK)
600   CALL HORIZ2(ADOT,NA,PER,G, 16 ,WORK,V,L,NFG,DK,TK)
      K=0
      DO 30 I=2, 16 ,2
      K=K+1
      VORD(I,LL,MOD)=SDOT(K)
      DIVD(I,LL,MOD)=ADOT(K+JSEV)
      COMD(I,LL,MOD)=ADOT(K+JEVPOD)
30    CONTINUE
      K=0
      DO 40 I=1, 17 ,2
      K=K+1
      VORD(I,LL,MOD)=ADOT(K)
      DIVD(I,LL,MOD)=SDOT(K+JSOD)
      COMD(I,LL,MOD)=SDOT(K+JEVPOD)
40    CONTINUE
1000  CONTINUE
      IF(NFILES.NE.1) REWIND NFG
2000  CONTINUE
      REWIND NFG
      RETURN
      END
