C
C
      SUBROUTINE  BESSJ0 (X,BJ)
C
C     ----------------------------------------------------------------
C
C       SUBROUTINE PURPOSE:
C       EVALUATION OF BESSEL FUNCTION OF THE 1ST KIND AND ZERO ORDER.
C
C     ----------------------------------------------------------------
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C
      PI = 3.14159265359D0
      IF (X.LT.12.0) THEN
         BJ=1.0
         BBJ=1.0
         BK=0.0
         F=-1.0
         DO 50 I=1,200
            BBJ=BBJ*X**2/(4.*DBLE(I)*DBLE(I))
            BJ=BJ+BBJ*F
            IF (I.GT.2.AND.DABS(BK-BJ).LT.1.D-9) RETURN
            BK=BJ
            F=-F
50       CONTINUE
      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      BJ = BZ*(DCOS(X-0.25*PI)*BY1-DSIN(X-0.25*PI)*BY2)
      ENDIF
C
      RETURN
      END
