complex function csqrt (z) c april 1977 version. w. fullerton, c3, los alamos scientific lab. complex z external cabs, sqrt c x = real (z) y = aimag (z) r = cabs (z) c if (r.eq.0.) csqrt = (0.0, 0.0) if (r.eq.0.) return c xtmp = sqrt ((r+abs(x))*0.5) ytmp = y*0.5/xtmp c if (x.ge.0.) csqrt = cmplx (xtmp, ytmp) if (y.eq.0.) y = 1. if (x.lt.0.) csqrt = cmplx (abs(ytmp), sign(xtmp,y)) c return end