C
C
      SUBROUTINE  BESSJ1 (X,BJ)
C
C     ------------------------------------------------------------
C
C       SUBROUTINE PURPOSE:
C       EVALUATION OF BESSEL FUNCTION OF 1ST KIND AND 1ST ORDER.
C
C     ------------------------------------------------------------
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C
      PI = 3.14159265359D0
C      write (8,*) 'xxxx',x,bj
      IF (X.LT.12.0) THEN
         BJ=X/2.
         BBJ=BJ
         BK=0.0
         F=-1.0
C        write (8,*) 'bjbjbj',bj  
         DO 50 I=1,200
            BBJ=BBJ*X*X/(4.*FLOAT(I)*(I+1))
            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.375/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-1)*(3-4*K)*(5-4*K)/
     .      (128.0*K*(2*K-1)*X*X)
            BY1 = BY1+F*BS1
            IF (ABS(BS1).LT.1.D-9) GO TO 150
            BS2 = BS2*(4*K+1)*(4*K+3)*(3-4*K)*(1-4*K)/
     .            (128.0*(2*K+1)*K*X*X)
            BY2 = BY2+F*BS2
            F = -F
100      CONTINUE
150      BJ = BZ*(DCOS(X-0.75*PI)*BY1-DSIN(X-0.75*PI)*BY2)
C      write (8,*) 'bjbzxpiby1by2',bj,bz,x,pi,by1,by2
      ENDIF
C
      RETURN
      END

