program pi3
! pi as integral
!! flawed !!
use kinds
implicit none
integer(kind=INT4) :: n, i
real(kind=REAL8) :: h, x, sum, pi
print*, 'enter number of intervals:'
read*, n
h = 1.0/n
sum = 0.0
!$OMP PARALLEL DO PRIVATE(x, sum)
do i=1,n
x = h*(i-0.5)
sum = sum + 4.0 / (1.0 + x*x)
enddo
!$OMP END PARALLEL DO
pi = h*sum
print *, pi
end program pi3