C
C *** BESSEL FUNCTION J1(X), N1(X)
C
      SUBROUTINE BESJN1(X,BJ1,BN1)
C
      IMPLICIT REAL*8 (A-H,O-Z)
      DATA C0,C1,C2,C3,C4,C5,C6,C7,C8,C9
     * /  1.22494472        D-8, -3.929965711       D-7,
     *    8.9514968720      D-6, -1.612440490740    D-4,
     *    2.2574925903842   D-3, -2.37037026763209  D-2,
     *    1.777777775582676 D-1, -8.888888888615124 D-1,
     *    2.6666666666649150D 0, -3.9999999999999563D 0  /
      DATA D0,D1,D2,D3,D4,D5,D6,D7,D8,D9,D10,D11
     * /  2.3353113         D-9, -8.71498135        D-8,
     *    2.3316556575      D-6, -5.00978325295     D-5,
     *    8.533226991090    D-4, -1.11766285197065  D-2,
     *    1.080130262837708 D-1, -7.271013435638566 D-1,
     *    3.1262109002217823D 0, -7.3980378533256488D 0,
     *    6.8529249642057360D 0,  3.9325615210260295D-1  /
      DATA E0,E1,E2,E3,E4,E5,E6,E7,E8,E9,E10,E11,E12,E13,E14,E15
     * /   4.84682           D-12, -2.280090          D-11,
     *     6.313256          D-11, -5.2574110         D-10,
     *     7.81894200        D- 9, -5.92404185        D- 9,
     *    -5.9222983079      D- 7, -6.1872869462      D- 7,
     *     5.249583490136    D- 5, -4.13703795176     D- 6,
     *    -2.35357444227453  D- 3,  7.6458541141893   D- 4,
     *     5.392388944881264 D- 2, -3.716528343506466 D- 2,
     *    -3.3809025392727920D- 1,  1.4786314339122685D- 1  /
      DATA F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14
     * /   1.78737           D-12,  1.601135          D-11,
     *    -3.8677585         D-10, -2.37356163        D- 9,
     *     5.432238759       D- 8,  2.6412212075      D- 7,
     *    -5.39680775206     D- 6, -1.797021894410    D- 5,
     *     3.3358852634720   D- 4,  6.7436676916589   D- 4,
     *    -1.120670091199092 D- 2, -9.47014978074827  D- 3,
     *     1.4701028926435867D- 1,  1.728843275053138 D- 2,
     *    -3.0266723702418487D- 1                           /
      DATA G0,G1,G2,G3,G4,G5,G6,G7,G8,G9,G10,G11,G12,G13,G14
     * /  -1.07463           D-12,  2.778003          D-11,
     *     2.0080 677        D-10, -4.75788198        D- 9,
     *    -2.6460 77937      D- 8,  5.7071424129      D- 7,
     *     2.32181314997     D- 6, -4.528596911743    D- 5,
     *    -1.2058288258765   D- 4,  2.11709460137864  D- 3,
     *     2.96574486954234  D- 3, -4.716051742840817 D- 2,
     *    -1.918838969353708 D- 2,  3.0074824530274775D- 1,
     *    -4.68282348234583  D- 3                           /
      DATA H0,H1,H2,H3,H4,H5,H6,H7,H8,H9,H10,H11,H12,H13,H14
     * /   2.21931           D-12,  4.11634           D-12,
     *    -4.3816515         D-10, -5.7599652         D-10,
     *     6.230613774       D- 8,  4.885713666       D- 8,
     *    -6.10299268189     D- 6, -1.70664050678     D- 6,
     *     3.7656506609458   D- 4, -6.721328811703    D- 5,
     *    -1.260105985120454 D- 2,  6.82955038740438  D- 3,
     *     1.6844608042350780D- 1, -1.1208094379604528D- 1,
     *    -3.2757913759146522D- 1                           /
      DATA A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10
     * /  -3.0207732         D-10,  2.08062912       D-9,
     *    -7.00035699        D- 9,  1.655768548      D-8,
     *    -3.558232648       D- 8,  8.955040706      D-8,
     *    -3.2722783265      D- 7,  2.05931893593    D-6,
     *    -2.808872167333    D- 5,  1.46097026511633 D-3,
     *     7.9788456080286546D- 1                           /
      DATA B0,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12
     * /   9.4650569         D-10, -7.05369184       D-9,
     *     2.464612368       D- 8, -5.514232274      D-8,
     *     9.343285420       D- 8, -1.4024484043     D-7,
     *     2.2297669562      D- 7, -4.4752033584     D-7,
     *     1.29573186799     D- 6, -6.06767597238    D-6,
     *     5.407079074732    D- 5, -1.27834898198997 D-3,
     *     2.9920671030107448D- 1                           /
      DATA PI2,PI4
     *   /  0.63661 97723 67581 34D0, 0.78539 81633 97448 31D0 /
C
      AX=DABS(X)
      IF (AX .LT. 8.797D-77) GO TO 60
      IF (AX .GE. 1.0D12) GO TO 50
      IF (AX .GE. 8.0D0) GO TO 30
      IF (AX .GE. 6.0D0) GO TO 20
      IF (AX .GE. 4.0D0) GO TO 10
C
C     0 < !X! < 4
C
      Y=X*0.25D0
      Z=Y*Y
      BJ1=((((((((((C0*Z +C1)*Z +C2)*Z +C3)*Z +C4)*Z +C5)*Z +C6)*Z
     *       +C7)*Z +C8)*Z +C9)*Z + 2.0D0) *Y
      BN1=((((((((((((D0*Z +D1)*Z +D2)*Z +D3)*Z +D4)*Z +D5)*Z +D6)*Z
     *       +D7)*Z +D8)*Z +D9)*Z +D10)*Z +D11)*Z -PI2) /X
      BN1=PI2*BJ1*DLOG(AX*0.5D0) +BN1
      GO TO 9999
C
C     4 <= !X! < 6
C
   10 Z=X-5.0D0
      BJ1=(((((((((((((H0*Z +H1)*Z +H2)*Z +H3)*Z +H4)*Z +H5)*Z
     *       +H6)*Z +H7)*Z +H8)*Z +H9)*Z +H10)*Z +H11)*Z +H12)*Z
     *       +H13)*Z +H14
      BN1=((((((((((((((E0*Z +E1)*Z +E2)*Z +E3)*Z +E4)*Z +E5)*Z
     *       +E6)*Z +E7)*Z +E8)*Z +E9)*Z +E10)*Z +E11)*Z +E12)*Z
     *       +E13)*Z +E14)*Z +E15
      GO TO 40
C
C     6 <= !X! < 8
C
   20 Z=X-7.0D0
      BJ1=(((((((((((((G0*Z +G1)*Z +G2)*Z +G3)*Z +G4)*Z +G5)*Z
     *       +G6)*Z +G7)*Z +G8)*Z +G9)*Z +G10)*Z +G11)*Z +G12)*Z
     *       +G13)*Z +G14
      BN1=(((((((((((((F0*Z +F1)*Z +F2)*Z +F3)*Z +F4)*Z +F5)*Z
     *       +F6)*Z +F7)*Z +F8)*Z +F9)*Z +F10)*Z +F11)*Z +F12)*Z
     *       +F13)*Z +F14
      GO TO 40
C
C     8 <= !X! < 1.0D12
C
   30 Z=64.0D0/(X*X)
      A=(((((((((A0*Z +A1)*Z +A2)*Z +A3)*Z +A4)*Z +A5)*Z +A6)*Z +A7)*Z
     *       +A8)*Z +A9)*Z +A10
      B=((((((((((((B0*Z +B1)*Z +B2)*Z +B3)*Z +B4)*Z +B5)*Z +B6)*Z
     *       +B7)*Z +B8)*Z +B9)*Z +B10)*Z +B11)*Z +B12) /AX
      Q=X-PI4
      CC= DCOS(Q)
      CS= DSIN(Q)
      CQ= DSQRT(AX)
      BJ1=(A*CS + B*CC) /CQ
      BN1=(B*CS - A*CC) /CQ
C
   40 IF (AX .LT. 0.0D0) THEN
      BJ1=-BJ1
      BN1=-BN1
      END IF
      GO TO 9999
C
C     PARAMETER ERROR
C
   50 BJ1= 0.D0
      BN1= 0.D0
      GO TO 9999
C
   60 BJ1= 0.0D0
      BN1=-1.0D75
C
 9999 RETURN
      END
