C
C *** COMPLEX BESSEL FUNCTION J0(X) AND N0(X) ***
C
      SUBROUTINE CJN0(X,CJ0,CN0)
C
      IMPLICIT REAL*8 (A-H,O-Z)
      COMPLEX*16 X,Z,CJ0,CN0,A,B,Q,CC,CS,CQ
     *          ,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10
     *          ,D0,D1,D2,D3,D4,D5,D6,D7,D8,D9,D10,D11,D12,D13
     *          ,E0,E1,E2,E3,E4,E5,E6,E7,E8,E9,E10,E11,E12,E13,E14
     *          ,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10
     *          ,B0,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12
     *          ,F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14
     *          ,G0,G1,G2,G3,G4,G5,G6,G7,G8,G9,G10,G11,G12,G13,G14,G15
     *          ,H0,H1,H2,H3,H4,H5,H6,H7,H8,H9,H10,H11
      DATA C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10
     * / (-2.2270614         D-9, 0.D0), ( 7.85940046        D-8, 0.D0),
     *   (-1.9891965786      D-6, 0.D0), ( 4.03109603859     D-5, 0.D0),
     *   (-6.449978225950    D-4, 0.D0), ( 7.9012341828039   D-3, 0.D0),
     *   (-7.11111110046304  D-2, 0.D0), ( 4.444444444257695 D-1, 0.D0),
     *   (-1.7777777777758446D 0, 0.D0), ( 3.9999999999998966D 0, 0.D0),
     *   (-3.9999999999999978D 0, 0.D0)                                /
      DATA D0,D1,D2,D3,D4,D5,D6,D7,D8,D9,D10,D11,D12,D13
     * / ( 3.315018          D-11,0.D0), ( 4.697063          D-11,0.D0),
     *   (-5.66336210        D-9, 0.D0), (-4.88429867        D-9, 0.D0),
     *   ( 6.7810966225      D-7, 0.D0), ( 2.1332909858      D-7, 0.D0),
     *   (-5.379500918201    D-5, 0.D0), ( 1.120221502384    D-5, 0.D0),
     *   ( 2.52021197018629  D-3, 0.D0), (-1.70738759690737  D-3, 0.D0),
     *   (-5.614869347449754 D-2, 0.D0), ( 5.604047189802616 D-2, 0.D0),
     *   ( 3.2757913759146509D-1, 0.D0), (-1.7759677131433834D-1, 0.D0)/
      DATA E0,E1,E2,E3,E4,E5,E6,E7,E8,E9,E10,E11,E12,E13,E14
     * / (-1.98650           D-12,0.D0), (-1.517802          D-11,0.D0),
     *   ( 3.9649790         D-10,0.D0), ( 2.40512241        D-9, 0.D0),
     *   (-5.707143476       D-8, 0.D0), (-2.5797893105      D-7, 0.D0),
     *   ( 5.66074614693     D-6, 0.D0), ( 1.722612595802    D-5, 0.D0),
     *   (-3.5284910023231   D-4, 0.D0), (-5.9314897388202   D-4, 0.D0),
     *   ( 1.179012935710246 D-2, 0.D0), ( 6.39612989784324  D-3, 0.D0),
     *   (-1.5037412265137390D-1, 0.D0), ( 4.68282348234590  D-3, 0.D0),
     *   ( 3.0007927051955560D-1, 0.D0)                                /
      DATA A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10
     * / ( 2.8228605          D-10,0.D0), (-1.94155134      D-9, 0.D0),
     *   ( 6.51602613         D-9, 0.D0), (-1.533982923     D-8, 0.D0),
     *   ( 3.267679187        D-8, 0.D0), (-8.099284883     D-8, 0.D0),
     *   ( 2.8872150072       D-7, 0.D0), (-1.74249896802   D-6, 0.D0),
     *   ( 2.184678334973     D-5, 0.D0), (-8.7658215906110 D-4, 0.D0),
     *   ( 0.79788456080286526D 0, 0.D0)                              /
      DATA B0,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12
     * / (-8.9331052         D-10, 0.D0), ( 6.65327442      D-9, 0.D0),
     *   (-2.322479945       D- 8, 0.D0), ( 5.187839807     D-8, 0.D0),
     *   (-8.765163373       D- 8, 0.D0), ( 1.3089752200    D-7, 0.D0),
     *   (-2.0632292049      D- 7, 0.D0), ( 4.0856346318    D-7, 0.D0),
     *   (-1.15933062842     D- 6, 0.D0), ( 5.25865147508   D-6, 0.D0),
     *   (-4.423973781374    D- 5, 0.D0), ( 9.1310641570497 D-4, 0.D0),
     *   (-9.973557010035815 D- 2, 0.D0)                              /
      DATA H0,H1,H2,H3,H4,H5,H6,H7,H8,H9,H10,H11
     * / ( 3.4432403         D-9, 0.D0), (-1.175592825       D-7, 0.D0),
     *   ( 2.8512737759      D-6, 0.D0), (-5.49344073691     D-5, 0.D0),
     *   ( 8.276591200190    D-4, 0.D0), (-9.4202584419331   D-3, 0.D0),
     *   ( 7.72372081288392  D-2, 0.D0), (-4.261441276304766 D-1, 0.D0),
     *   ( 1.4216343895861494D 0, 0.D0), (-2.3498510134188587D 0, 0.D0),
     *   ( 1.0766114686838581D 0, 0.D0), ( 3.6746690519661597D-1, 0.D0)/
      DATA G0,G1,G2,G3,G4,G5,G6,G7,G8,G9,G10,G11,G12,G13,G14,G15
     * / ( 1.50410           D-12,0.D0), (-5.72117           D-12,0.D0),
     *   ( 4.050146          D-11,0.D0), (-6.4960948         D-10,0.D0),
     *   ( 5.3845950         D-10,0.D0), ( 5.922131699       D- 8,0.D0),
     *   ( 6.874770130       D- 8,0.D0), (-6.56197858169     D- 6,0.D0),
     *   ( 5.9100539363      D- 7,0.D0), ( 3.9226240684696   D- 4,0.D0),
     *   (-1.5291708227790   D- 4,0.D0), (-1.348097236217831 D- 2,0.D0),
     *   ( 1.238842781168767 D- 2,0.D0), ( 1.6904512696363842D- 1,0.D0),
     *   (-1.4786314339122686D- 1,0.D0), (-3.0851762524903378D- 1,0.D0)/
      DATA F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14
     * / (-1.14460           D-12,0.D0), ( 2.930515          D-11,0.D0),
     *   ( 1.9780007         D-10,0.D0), (-4.93772861        D- 9,0.D0),
     *   (-2.641221656       D- 8,0.D0), ( 5.9964479378      D- 7,0.D0),
     *   ( 2.24627737107     D- 6,0.D0), (-4.765550355443    D- 5,0.D0),
     *   (-1.1239446152872   D- 4,0.D0), ( 2.24134018235420  D- 3,0.D0),
     *   ( 2.36753744518725  D- 3,0.D0), (-4.900342975478215 D- 2,0.D0),
     *   (-8.64421637526570  D- 3,0.D0), ( 3.0266723702418476D- 1,0.D0),
     *   (-2.5949743967209265D- 2,0.D0)                                /
      DATA PI2,PI4
     *   /  0.63661 97723 67581 34D0, 0.78539 81633 97448 31D0 /
C
      AX=CDABS(X)
      IF (AX .EQ. 0.0D0 ) GO TO 50
      IF (AX .GE. 1.0D12) GO TO 40
      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     !X! < 4
C
      Z=X*X*0.0625D0
      CJ0=((((((((((C0*Z +C1)*Z +C2)*Z +C3)*Z +C4)*Z +C5)*Z +C6)*Z
     *    +C7)*Z +C8)*Z +C9)*Z +C10)*Z +(1.0D0,0.0D0)
      CN0=((((((((((H0*Z +H1)*Z +H2)*Z +H3)*Z +H4)*Z +H5)*Z +H6)*Z
     *    +H7)*Z +H8)*Z +H9)*Z +H10)*Z +H11
      CN0=PI2*CJ0*CDLOG(X*0.5D0) +CN0
      GO TO 9999
C
C     4 <= !X! < 6
   10 Z=X-DCMPLX(5.0D0,0.D0)
      CJ0=((((((((((((D0*Z+ D1)*Z+ D2)*Z+ D3)*Z+ D4)*Z+ D5)*Z
     *       +D6)*Z+ D7)*Z+ D8)*Z+ D9)*Z+ D10)*Z+ D11)*Z+ D12)*Z+ D13
      CN0=((((((((((((((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)*Z +G15
      GO TO 9999
C
C     6 <= !X! < 8
C
   20 Z=X-DCMPLX(7.0D0,0.D0)
      CJ0=(((((((((((((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
      CN0=(((((((((((((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 9999
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) / X
      Q=X-DCMPLX(PI4,0.D0)
      CC=CDCOS(Q)
      CS=CDSIN(Q)
      CQ=CDSQRT(X)
      CJ0=(A*CC - B*CS) /CQ
      CN0=(A*CS + B*CC) /CQ
      GO TO 9999
C
C     PARAMETER ERROR
C
   40 CJ0=(0.0D0,0.D0)
      CN0=(0.0D0,0.0D0)
      GO TO 9999
C
   50 CJ0=( 1.0D 0,0.D0)
      CN0=(-1.0D75,0.D0)
C
 9999 RETURN
      END
