parameter(n=2,pi=3.1415927)
dimension a(n),b(n),x(n)
external fun
a(1)=0; b(1)=pi;
a(2)=0; b(2)=pi;
m=39000
call mcarlo(n,a,b,x,fun,m,res,eps)
print *,'res=',res,' \teps=',eps
!print *,'ans=',pi,' \terr=',abs(pi-res)
end

function fun(n,p)
dimension p(n)
x=p(1); y=p(2)
!r=sqrt(x*x+y*y)
!if(r<1)then
!	fun=1
!else
!	fun=0
!end if
fun=exp(sin(x)**2+cos(y)**2)
return; end
