      SUBROUTINE WSQRT (XR, XI, YR, YI)
      IMPLICIT NONE
C
C Y = SQRT(X) WITH YR.GE.0.0 AND SIGN(YI).EQ.SIGN(XI)
C
      DOUBLE PRECISION XR, XI, YR, YI
C
      DOUBLE PRECISION S, TR, TI
C
      DOUBLE PRECISION PYTHAG, FLOP
C
C
      TR = XR
      TI = XI
      S = DSQRT (0.5D0*(PYTHAG (TR, TI)+DABS (TR)))
      IF (TR.GE.0.0D0) YR = FLOP (S)
      IF (TI.LT.0.0D0) S = -S
      IF (TR.LE.0.0D0) YI = FLOP (S)
      IF (TR.LT.0.0D0) YR = FLOP (0.5D0*(TI/YI))
      IF (TR.GT.0.0D0) YI = FLOP (0.5D0*(TI/YR))
C
      RETURN
      END
