#include "fpreproc/library_names.h"
#include "fpreproc/f77_dcomplx.h"
#include "fpreproc/fp_const.h"
*DECK DBESK0
      REAL*8 FUNCTION DBESK0 (X)
C***BEGIN PROLOGUE  DBESK0
C***PURPOSE  Compute the modified (hyperbolic) Bessel function of the
C            third kind of order zero.
C***LIBRARY   SLATEC (FNLIB)
C***CATEGORY  C10B1
C***TYPE      REAL*8 (BESK0-S, DBESK0-D)
C***KEYWORDS  FNLIB, HYPERBOLIC BESSEL FUNCTION,
C             MODIFIED BESSEL FUNCTION, ORDER ZERO, SPECIAL FUNCTIONS,
C             THIRD KIND
C***AUTHOR  Fullerton, W., (LANL)
C***DESCRIPTION
C
C DBESK0(X) calculates the double precision modified (hyperbolic)
C Bessel function of the third kind of order zero for double
C precision argument X.  The argument must be greater than zero
C but not so large that the result underflows.
C
C Series for BK0        on the interval  0.          to  4.00000E+00
C                                        with weighted error   3.08E-33
C                                         log weighted error  32.51
C                               significant figures required  32.05
C                                    decimal places required  33.11
C
C***REFERENCES  (NONE)
C***ROUTINES CALLED  D1MACH, DBESI0, DBSK0E, DCSEVL, INITDS, XERMSG
C***REVISION HISTORY  (YYMMDD)
C   770701  DATE WRITTEN
C   890531  Changed all specific intrinsics to generic.  (WRB)
C   890531  REVISION DATE from Version 3.2
C   891214  Prologue converted to Version 4.0 format.  (BAB)
C   900315  CALLs to XERROR changed to CALLs to XERMSG.  (THJ)
C***END PROLOGUE  DBESK0
C============
C idecl:  explicitize implicit INTEGER declarations:
      IMPLICIT NONE
      INTEGER ntk0,initds
C============
      REAL*8 X, BK0CS(16), XMAX, XMAXT, XSML, Y,
     1  D1MACH, DCSEVL, DBESI0, DBSK0E
      LOGICAL FIRST
      SAVE BK0CS, NTK0, XSML, XMAX, FIRST
      DATA BK0CS(  1) / -CONST(.353273932339027687201140060063153,-1)/
      DATA BK0CS(  2) / +CONST(.344289899924628486886344927529213,+0)/
      DATA BK0CS(  3) / +CONST(.359799365153615016265721303687231,-1)/
      DATA BK0CS(  4) / +CONST(.126461541144692592338479508673447,-2)/
      DATA BK0CS(  5) / +CONST(.228621210311945178608269830297585,-4)/
      DATA BK0CS(  6) / +CONST(.253479107902614945730790013428354,-6)/
      DATA BK0CS(  7) / +CONST(.190451637722020885897214059381366,-8)/
      DATA BK0CS(  8) / +CONST(.103496952576336245851008317853089,-10)/
      DATA BK0CS(  9) / +CONST(.425981614279108257652445327170133,-13)/
      DATA BK0CS( 10) / +CONST(.137446543588075089694238325440000,-15)/
      DATA BK0CS( 11) / +CONST(.357089652850837359099688597333333,-18)/
      DATA BK0CS( 12) / +CONST(.763164366011643737667498666666666,-21)/
      DATA BK0CS( 13) / +CONST(.136542498844078185908053333333333,-23)/
      DATA BK0CS( 14) / +CONST(.207527526690666808319999999999999,-26)/
      DATA BK0CS( 15) / +CONST(.271281421807298560000000000000000,-29)/
      DATA BK0CS( 16) / +CONST(.308259388791466666666666666666666,-32)/
      DATA FIRST /.TRUE./
C***FIRST EXECUTABLE STATEMENT  DBESK0
      IF (FIRST) THEN
         NTK0 = INITDS (BK0CS, 16, CONST(0.1,0)*AREAL(D1MACH(3)))
         XSML = SQRT(CONST(4.0,0)*D1MACH(3))
         XMAXT = -LOG(D1MACH(1))
         XMAX = XMAXT -
     +      CONST(0.5,0)*XMAXT*LOG(XMAXT)/(XMAXT+CONST(0.5,0))
      ENDIF
      FIRST = .FALSE.
C
      IF (X .LE. CONST(0.,0)) CALL XERMSG ('SLATEC', 'DBESK0',
     +   'X IS ZERO OR NEGATIVE', 2, 2)
      IF (X.GT.CONST(2.0,0)) GO TO 20
C
      Y = CONST(0.,0)
      IF (X.GT.XSML) Y = X*X
      DBESK0 = -LOG(CONST(0.5,0)*X)*DBESI0(X) -
     1   CONST(0.25,0)+ DCSEVL (CONST(.5,0)*Y-CONST(1.,0),
     1   BK0CS, NTK0)
      RETURN
C
 20   DBESK0 = CONST(0.,0)
      IF (X .GT. XMAX) CALL XERMSG ('SLATEC', 'DBESK0',
     +   'X SO BIG K0 UNDERFLOWS', 1, 1)
      IF (X.GT.XMAX) RETURN
C
      DBESK0 = EXP(-X) * DBSK0E(X)
C
      RETURN
      END
! 22Jun2000 fgtok -s r8_precision.sub "r8con.csh conversion"
! 22Jun2000 fgtok
! 22Jun2000 fgtok
! 22Jun2000 fgtok
