      subroutine fork(lx,cx,signi)
c
c  Subroutine FORK calculates the Fourier transform of a one-
c  dimensional array.  Algorithm from Claerbout, J.F., 
c  "Fundamentals of Geophysical Data Processing with Applications 
c  to Petroleum Prospecting", McGraw-Hill, 1976.
c
c  Input/output parameters:
c    Complex array cx of length lx is the input array.  Upon 
c    return, cx contains the transformed array.  Length of 
c    array must be a power of 2.  If signi=-1., then the forward 
c    calculation is performed; if signi=1., the inverse transform 
c    is performed.  
c
      complex cx(2050),carg,cexp,cw,ctemp
      j=1
      sc=sqrt(1./lx)
      do 5 i=1,lx
         if(i.gt.j)go to 2
            ctemp=cx(j)*sc
            cx(j)=cx(i)*sc
            cx(i)=ctemp
    2    m=lx/2
    3    if(j.le.m)go to 5
            j=j-m
            m=m/2
            if(m.ge.1)go to 3
    5    j=j+m
      l=1
    6 istep=2*l
      do 8 m=1,l
         carg=(0.,1.)*(3.14159265*signi*(m-1))/l
         cw=cexp(carg)
         do 8 i=m,lx,istep
            ipl=i+l
            ctemp=cw*cx(ipl)
            cx(ipl)=cx(i)-ctemp
    8       cx(i)=cx(i)+ctemp
      l=istep
      if(l.lt.lx)go to 6
      return
      end
