       program integrate
c  Compute the integral of f(x) from a to b using
c  the right endpoint rule with n intervals.  I.e.,
c  compute
c
c      h [f(a+h) + f(a+2h) + ... + f(a+nh)],
c
c  with h=(b-a)/n.
c
c  Notes: (1) This program uses features of Fortran 90.
c  Simple modifications are needed for Fortran 77.
c  (2) This program is for teaching purposes.  It has
c  problems!

c define a, b, and n
      a = 1.
      b = 4.
      n = 30
c compute h, initialize a and sum
      h = (b-a)/n
      x = a
      sum = 0.0
c loop through sum, stopping when we hit b
      do
        x = x+h
        sum = sum + f(x)
        if (x == b) then
          print*,h*sum
          stop
        endif
      end do
c      
      end

      function f(x)
      f = sin(x)*exp(x)
      return
      end
