Debian Codegraph @

gcc/testsuite/gfortran.dg/bessel_6.f90

raw
1 ! { dg-add-options ieee }
2 !
3 ! PR fortran/36158
4 ! PR fortran/33197
5 !
6 ! Run-time tests for transformations BESSEL_JN
7 !
8 implicit none
9 real,parameter :: values(*) = [0.0, 0.5, 1.0, 0.9, 1.8,2.0,3.0,4.0,4.25,8.0,34.53, 475.78]
10 real,parameter :: myeps(size(values)) = epsilon(0.0) &
11 * [2, 7, 5, 6, 9, 12, 12, 7, 7, 8, 98, 15 ]
12 ! The following is sufficient for me - the values above are a bit
13 ! more tolerant
14 ! * [0, 5, 3, 4, 6, 7, 7, 5, 5, 6, 66, 4 ]
15 integer,parameter :: mymax(size(values)) = &
16 [100, 17, 23, 21, 27, 28, 32, 35, 31, 41, 47, 37 ]
17 integer, parameter :: Nmax = 100
18 real :: rec(0:Nmax), lib(0:Nmax)
19 integer :: i
20
21 do i = 1, ubound(values,dim=1)
22 call compare(mymax(i), values(i), myeps(i))
23 end do
24
25 contains
26
27 subroutine compare(mymax, X, myeps)
28
29 integer :: i, nit, mymax
30 real X, myeps, myeps2
31
32 rec(0:mymax) = BESSEL_JN(0, mymax, X)
33 lib(0:mymax) = [ (BESSEL_JN(i, X), i=0,mymax) ]
34
35 !print *, 'YN for X = ', X, ' -- Epsilon = ',epsilon(x)
36 do i = 0, mymax
37 ! print '(i2,2e17.9,e12.2,f18.10,2l3)', i, rec(i), lib(i), &
38 ! rec(i)-lib(i), ((rec(i)-lib(i))/rec(i))/epsilon(x), &
39 ! rec(i) == lib(i), abs((rec(i)-lib(i))/rec(i)) < myeps
40 if (rec(i) == lib(i)) CYCLE
41 if (abs((rec(i)-lib(i))/rec(i)) > myeps) &
42 STOP 1
43 end do
44
45 end
46 end