      complex function catan2 (csn, ccs)
c april 1977 version.  w. fullerton, c3, los alamos scientific lab.
      complex csn, ccs, catan
      external cabs, catan
      data pi / 3.1415926535 8979323846e0 /
c
      if (cabs(ccs).eq.0.) go to 10
c
      catan2 = catan (csn/ccs)
      if (real(ccs).lt.0.) catan2 = catan2 + pi
      if (real(catan2).gt.pi) catan2 = catan2 - 2.0*pi
      return
c
 10   if (cabs(csn).eq.0.) call seteru (
     1  34hcatan2  called with both args zero, 34, 1, 2)
c
      catan2 = cmplx (sign(0.5*pi,real(csn)), 0.0)
c
      return
      end
