program integration_with_doloop ! ! This program computes the numerical integration of cosine function ! ! Written by: Kadin Tseng ! Date written: September 19, 2012 ! implicit none real, parameter :: pi=3.141593 real :: a, b, h, integ, integral integer :: n, m a = 0.0 ! lower limit of integration b = pi/2 ! upper limit of integration do n=1,4 ! number of cases to study !m = 25*2**(n-1) ! define number of increments as a function of n m = 25*2**n ! define number of increments as a function of n h = (b - a)/m ! increment length integ = integral(a, h, m) ! perform integration print*, 'No. of increments = ',m,' Integral value is ', integ enddo end program integration_with_doloop