      program pi_v1 ! Bernd Berg Aug 26 2007.
c pi estimate through area of unit circle - version 1.
      include '../../ForLib/implicit.sta'
      include '../../ForLib/constants.par'
      parameter(iuo=6,iud=10,miuo=-iuo,iseed1=0,iseed2=0,ndat=10**6)
c
      write(iuo,'(/," pi analytical =",1F10.5)') pi
      call rmaset(miuo,iud,iseed1,iseed2,'ranmar.d')
      events=zero
      do idat=1,ndat
        call ranmar(xr)
        call ranmar(yr)
        if(xr**2+yr**2.lt.one) events=events+one ! estimate of area.
      end do
      pi_est=4*events/ndat
      write(iuo,'(" pi estimate =  ",1F10.5)') pi_est
      write(iuo,'(" difference =   ",1F10.5)') (pi-pi_est)
c
      stop
      end

      include '../../ForLib/rmaset.f'
      include '../../ForLib/ranmar.f'
      include '../../ForLib/rmasave.f'
