-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_adapquad.f90
68 lines (47 loc) · 1.3 KB
/
test_adapquad.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
module test_adapquad_funs
contains
subroutine testfun(n,xs,ys,vals,userptr)
use iso_c_binding
implicit double precision (a-h,o-z)
double precision :: xs(n),ys(n)
type(c_ptr) :: userptr
double precision :: vals(n)
vals = log(xs**2+ys**2)
end subroutine
subroutine testfun2(n,xs,vals,userptr)
use iso_c_binding
implicit double precision (a-h,o-z)
double precision :: xs(n)
type(c_ptr) :: userptr
double precision :: vals(n)
vals = log(xs**2)
end subroutine
end module
program test_adapquad
use utils
use adapquad
use iso_c_binding
use test_adapquad_funs
implicit double precision (a-h,o-z)
type(c_ptr) :: userptr
x1 = 0.0d0
y1 = 0.0d0
x2 = 1.0d0
y2 = 1.0d0
eps = epsilon(0.0d0)
eps = eps*100
call adaprect(ier,eps,x1,y1,x2,y2,testfun,userptr,val,ntotal)
val0 = -0.7360564926451580713514461869020719898259151660d0
call prind("integral value = ",val)
call prin2("relative error in value = ",abs((val-val0)/val0))
call prini("nodes in quadrature = ",ntotal)
call prina("")
x1 = 0.0d0
y1 = 0.0d0
call adapint(ier,eps,x1,x2,testfun2,userptr,val,ntotal)
val0 = -2.0d0
call prind("integral value = ",val)
call prin2("relative error in value = ",abs((val-val0)/val0))
call prini("nodes in quadrature = ",ntotal)
call prina("")
end program