C
C
      SUBROUTINE  BESSY0 (X,BJ0,BY)
C
C     ------------------------------------------------------------
C
C       SUBROUTINE PURPOSE:
C       EVALUATION OF BESSEL FUNCTION OF 2ND KIND AND ZERO ORDER.
C
C     ------------------------------------------------------------
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C
      PI = 3.14159265359D0
      GA = 0.57721566490D0
      IF (X.LT.12.0) THEN
         BY=X*X/4.0
         BM=1.
         BBY=BY
         BK=0.0
         F=-1.0
         DO 50 I=1,200
            BM=BM+1.0/DBLE(I+1)
            BBY=BBY*X*X/(4.0*DBLE(I+1)*DBLE(I+1))
            BY=BY+BBY*BM*F
            IF (I.GT.2.AND.DABS(BK-BY).LT.1.D-9) THEN
               BBY=BY+(DLOG(X/2.)+GA)*BJ0
               BY=BBY*2.0/PI
               RETURN
            ELSE
               BK=BY
               F=-F
            ENDIF
50       CONTINUE
         BBY=BY+(DLOG(X/2.)+GA)*BJ0
         BY=BBY*2.0/PI
      ELSE
         BS1 = 1.0
         BS2 = -0.125/X
         BY1 = BS1
         BY2 = BS2
         BZ = DSQRT(2.0/(PI*X))
         F = -1.0
         DO 100 K = 1,100
            BS1 = BS1*((4*K-1)*(4*K-3))**2/(128.0*K*(2*K-1)*X*X)
            BY1 = BY1+F*BS1
            IF (BS1.LT.1.D-9) GO TO 150
            BS2 = BS2*((4*K-1)*(4*K-3))**2/(128.0*(2*K+1)*K*X*X)
            BY2 = BY2+F*BS2
            F = -F
100      CONTINUE
150      BY = BZ*(DCOS(X-0.25*PI)*BY2+DSIN(X-0.25*PI)*BY1)
      ENDIF
C
      RETURN
      END
