      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      PI = 3.141592654 D0
C                         NUMBER OF MIDPOINT RULE INTERVALS
      N = 10000
      Smax = 100
      E = 40
      R = 0.1
      SIGMA = 0.2
      T = 0.5 
      S0 = 39 
      ALPHA = LOG(S0) + (R-0.5*SIGMA**2)*T
      H = (Smax-E)/N
      SUM = 0
      DO K=1,N
C                         S AT INTERVAL MIDPOINT
         S = E + (K-0.5)*H
C                         Z FROM FORMULA 4.4
         Z = LOG(S) - ALPHA
C                         P(0,Z) FROM FORMULA 4.3
         P = EXP(-Z**2/(2*SIGMA**2*T))/SQRT(2*PI*SIGMA**2*T)
         SUM = SUM + H*(S-E)/S*P
      END DO
C                         CURRENT VALUE OF OPTION
      SUM = SUM*EXP(-R*T)
      PRINT *, ' Integral = ',SUM
      STOP
      END
