PROGRAM WELLFUNC
C=======================================================================
C  WELL FUNCTION COMPUTATION BY SERIES
C  Nov. 30, 1981     Tucson, Arizona     Eiji Fukumori
C=======================================================================
      IMPLICIT REAL*8 ( A-H , O-Z )
      GAMMA = 0.5772156649D0
      ACCEPT = 1.D-12
C=======================================================================
      WRITE(*,*) ' TYPE IN A VALUE OF U'
      READ (*,*) U
      IF ( U .GT. 0.) THEN
      SUM = 0.D0
      TERM = -1.D0
      I = 0
      RINCRMNT = 2.*ACCEPT
      DO WHILE ( DABS(RINCRMNT) .GT. ACCEPT )
      I = I + 1
      TERM = -TERM*U/DFLOAT(I)
      TERMX = TERM/DFLOAT(I)
      SUM = SUM + TERMX
      RINCRMNT = TERMX/SUM
      END DO
      WELL = -GAMMA - DLOG(U) + SUM
      WRITE(*,*) ' W(',U,')=',WELL, '     I=', I
      END IF
      STOP
      END