c    @(#)poinit.f	1.3
c
      subroutine poinit (nperod,m,n,iex2,iex3,iex5,
     1                   n2pw,n2p3p,n2p3p5,ks3,
     1                   ks5,twocos)
      dimension        twocos(6*n+5*m)
c
      pi = acos(-1.0)
  101 np = n
      if (nperod.eq.1) np = np+1
      if (nperod.eq.3) np = np-1
      iex2 = 0
  102 k = np/2
      if (2*k.ne.np) go to 103
      iex2 = iex2+1
      np = k
      go to 102
  103 iex3 = 0
  104 k = np/3
      if (3*k.ne.np) go to 105
      iex3 = iex3+1
      np = k
      go to 104
  105 iex5 = 0
  106 k = np/5
      if (5*k.ne.np) go to 107
      iex5 = iex5+1
      np = k
      go to 106
  107 continue
      n2pw = 2**iex2
      n2p3p = n2pw*(3**iex3)
      n2p3p5 = n2p3p*(5**iex5)
      np = 1
      twocos(1) = 0.
      k = 1
      if (iex2.eq.0) go to 113
      l = iex2
      if (iex3+iex5.ne.0) go to 108
      if (nperod.eq.1) l = l-1
      if (l.eq.0) go to 142
  108     do 112 kount=1,l
          np = 2*np
              do 110 i=1,np
  109         twocos(k+i) = 2.*cos((i-.5)*pi/np)
  110         continue
  111     k = k+np
  112     continue
  113 if (iex3.eq.0) go to 118
      l = iex3
      if (iex5.ne.0) go to 114
      if (nperod.eq.1) l = l-1
      if (l.eq.0) go to 122
  114     do 117 kount=1,l
          np = 3*np
              do 116 i=1,np
  115         twocos(k+i) = 2.*cos((i-.5)*pi/np)
  116         continue
          k = k+np
  117     continue
  118 l = iex5
      if (nperod.eq.1) l = l-1
      if (l.le.0) go to 122
          do 121 kount=1,l
          np = 5*np
              do 120 i=1,np
  119         twocos(k+i) = 2.*cos((i-.5)*pi/np)
  120         continue
          k = k+np
  121     continue
  122 if (nperod.eq.1.or.nperod.eq.2) go to 128
      if (nperod.eq.0) go to 125
      npt2 = 2*np
          do 124 i=1,npt2
  123     twocos(k+i) = 2.*cos(i*pi/np)
  124     continue
      k = k+npt2
      go to 128
  125     do 127 i=1,np
  126     twocos(k+i) = 2.*cos(2.*i*pi/np)
  127     continue
      k = k+np
  128 np = n2p3p5
      if (iex5.eq.0) go to 137
      ks5 = k
          do 136 kount=1,iex5
          np = np/5
          npt2 = 2*np
              do 130 i=1,npt2
  129         twocos(k+i) = 2.*cos((i-.5)*pi/npt2)
  130         continue
          k = k+npt2
              do 132 i=1,np
              twocos(k+4*i-3) = 2.*cos((i-.8)*pi/np)
              twocos(k+4*i-2) = 2.*cos((i-.6)*pi/np)
              twocos(k+4*i-1) = 2.*cos((i-.4)*pi/np)
  131         twocos(k+4*i) = 2.*cos((i-.2)*pi/np)
  132         continue
          k = k+4*np
              do 134 i=1,np
              twocos(k+2*i-1) = 2.*cos((3*i-2)*pi/(3*np))
  133         twocos(k+2*i) = 2.*cos((3*i-1)*pi/(3*np))
  134         continue
  135     k = k+2*np
  136     continue
  137 if (iex3.eq.0) go to 142
      ks3 = k
          do 141 kount=1,iex3
          np = np/3
              do 139 i=1,np
              twocos(k+2*i-1) = 2.*cos((3*i-2)*pi/(3*np))
  138         twocos(k+2*i) = 2.*cos((3*i-1)*pi/(3*np))
  139         continue
  140     k = k+2*np
  141     continue
  142 return
      end
