      SUBROUTINE PRIMES(VORD,DIVD,COMD,GH,MODS,INOUT)
CJPB  COMPLEX*8
      COMPLEX
 
     1VORD( 17 , 17 , 7 ),
     2DIVD( 17 , 17 , 7 ),
     2COMD( 17 , 17 , 7 )
      DIMENSION GH( 7 )
C***  INOUT=-1 SCALE TO PRIMES,=+1 RETURN FROM PRIMES
      IF(INOUT)10,20,30
10    CONTINUE
      DO 4 K=1,MODS
      T=1./( 6370000. *SQRT(GH(K)))
      DO 3 LL=1, 17
      N=LL-2
      DO 2 I=1, 17
      N=N+1.
      F=1.
      IF(N.EQ.0)GO TO 1
      F=1./SQRT(N*(N+1.))
1     CONTINUE
      VORD(I,LL,K)=CMPLX(F*REAL(VORD(I,LL,K)),F*AIMAG(VORD(I,LL,K)))
      DIVD(I,LL,K)=CMPLX(-F*AIMAG(DIVD(I,LL,K)), F*REAL(DIVD(I,LL,K)))
      COMD(I,LL,K)=CMPLX(T*REAL(COMD(I,LL,K)),T*AIMAG(COMD(I,LL,K)))
2     CONTINUE
3     CONTINUE
4     CONTINUE
20    RETURN
30    CONTINUE
      DO 8 K=1,MODS
      T=     6370000. *SQRT(GH(K))
      DO 7 LL=1, 17
      N=LL-2
      DO 6 I=1, 17
      N=N+1.
      F=   SQRT(N*(N+1.))
      VORD(I,LL,K)=CMPLX(F*REAL(VORD(I,LL,K)),F*AIMAG(VORD(I,LL,K)))
      DIVD(I,LL,K)=CMPLX( F*AIMAG(DIVD(I,LL,K)),-F*REAL(DIVD(I,LL,K)))
      COMD(I,LL,K)=CMPLX(T*REAL(COMD(I,LL,K)),T*AIMAG(COMD(I,LL,K)))
6     CONTINUE
7     CONTINUE
8     CONTINUE
      RETURN
      END
