home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
prgramer
/
adaptor
/
examples
/
simple
/
pi.f
< prev
next >
Wrap
Text File
|
1993-11-30
|
513b
|
21 lines
c numerical integration to calculate pi
program pi
integer i, n
real*8 w, v(:), gsum, pi
print *, 'Input number of points : '
read *, n
call cm_timer_clear (0)
call cm_timer_start (0)
w = 1.0 / n
allocate (v(n))
v = ([1:n] -0.5 )* w
v = 4.0 / (1.0 + v * v)
gsum = sum (v)
call cm_timer_stop (0)
print *, 'pi ist approximated with ', gsum *w
call cm_timer_print (0)
deallocate (v)
end