1 | c intrinsic-unix-bessel.f
|
---|
2 | c
|
---|
3 | c Test Bessel function intrinsics.
|
---|
4 | c These functions are only available if provided by system
|
---|
5 | c
|
---|
6 | c David Billinghurst <David.Billinghurst@riotinto.com>
|
---|
7 | c
|
---|
8 | real x, a
|
---|
9 | double precision dx, da
|
---|
10 | integer i
|
---|
11 | integer*2 j
|
---|
12 | integer*1 k
|
---|
13 | integer*8 m
|
---|
14 | logical fail
|
---|
15 | common /flags/ fail
|
---|
16 | fail = .false.
|
---|
17 |
|
---|
18 | x = 2.0
|
---|
19 | dx = x
|
---|
20 | i = 2
|
---|
21 | j = i
|
---|
22 | k = i
|
---|
23 | m = i
|
---|
24 | c BESJ0 - Bessel function of first kind of order zero
|
---|
25 | a = 0.22389077
|
---|
26 | da = a
|
---|
27 | call c_r(BESJ0(x),a,'BESJ0(real)')
|
---|
28 | call c_d(BESJ0(dx),da,'BESJ0(double)')
|
---|
29 | call c_d(DBESJ0(dx),da,'DBESJ0(double)')
|
---|
30 |
|
---|
31 | c BESJ1 - Bessel function of first kind of order one
|
---|
32 | a = 0.57672480
|
---|
33 | da = a
|
---|
34 | call c_r(BESJ1(x),a,'BESJ1(real)')
|
---|
35 | call c_d(BESJ1(dx),da,'BESJ1(double)')
|
---|
36 | call c_d(DBESJ1(dx),da,'DBESJ1(double)')
|
---|
37 |
|
---|
38 | c BESJN - Bessel function of first kind of order N
|
---|
39 | a = 0.3528340
|
---|
40 | da = a
|
---|
41 | call c_r(BESJN(i,x),a,'BESJN(integer,real)')
|
---|
42 | call c_r(BESJN(j,x),a,'BESJN(integer*2,real)')
|
---|
43 | call c_r(BESJN(k,x),a,'BESJN(integer*1,real)')
|
---|
44 | call c_d(BESJN(i,dx),da,'BESJN(integer,double)')
|
---|
45 | call c_d(BESJN(j,dx),da,'BESJN(integer*2,double)')
|
---|
46 | call c_d(BESJN(k,dx),da,'BESJN(integer*1,double)')
|
---|
47 | call c_d(DBESJN(i,dx),da,'DBESJN(integer,double)')
|
---|
48 | call c_d(DBESJN(j,dx),da,'DBESJN(integer*2,double)')
|
---|
49 | call c_d(DBESJN(k,dx),da,'DBESJN(integer*1,double)')
|
---|
50 |
|
---|
51 | c BESY0 - Bessel function of second kind of order zero
|
---|
52 | a = 0.51037567
|
---|
53 | da = a
|
---|
54 | call c_r(BESY0(x),a,'BESY0(real)')
|
---|
55 | call c_d(BESY0(dx),da,'BESY0(double)')
|
---|
56 | call c_d(DBESY0(dx),da,'DBESY0(double)')
|
---|
57 |
|
---|
58 | c BESY1 - Bessel function of second kind of order one
|
---|
59 | a = 0.-0.1070324
|
---|
60 | da = a
|
---|
61 | call c_r(BESY1(x),a,'BESY1(real)')
|
---|
62 | call c_d(BESY1(dx),da,'BESY1(double)')
|
---|
63 | call c_d(DBESY1(dx),da,'DBESY1(double)')
|
---|
64 |
|
---|
65 | c BESYN - Bessel function of second kind of order N
|
---|
66 | a = -0.6174081
|
---|
67 | da = a
|
---|
68 | call c_r(BESYN(i,x),a,'BESYN(integer,real)')
|
---|
69 | call c_r(BESYN(j,x),a,'BESYN(integer*2,real)')
|
---|
70 | call c_r(BESYN(k,x),a,'BESYN(integer*1,real)')
|
---|
71 | call c_d(BESYN(i,dx),da,'BESYN(integer,double)')
|
---|
72 | call c_d(BESYN(j,dx),da,'BESYN(integer*2,double)')
|
---|
73 | call c_d(BESYN(k,dx),da,'BESYN(integer*1,double)')
|
---|
74 | call c_d(DBESYN(i,dx),da,'DBESYN(integer,double)')
|
---|
75 | call c_d(DBESYN(j,dx),da,'DBESYN(integer*2,double)')
|
---|
76 | call c_d(DBESYN(k,dx),da,'DBESYN(integer*1,double)')
|
---|
77 |
|
---|
78 | if ( fail ) call abort()
|
---|
79 | end
|
---|
80 |
|
---|
81 | subroutine failure(label)
|
---|
82 | c Report failure and set flag
|
---|
83 | character*(*) label
|
---|
84 | logical fail
|
---|
85 | common /flags/ fail
|
---|
86 | write(6,'(a,a,a)') 'Test ',label,' FAILED'
|
---|
87 | fail = .true.
|
---|
88 | end
|
---|
89 |
|
---|
90 | subroutine c_r(a,b,label)
|
---|
91 | c Check if REAL a equals b, and fail otherwise
|
---|
92 | real a, b
|
---|
93 | character*(*) label
|
---|
94 | if ( abs(a-b) .gt. 1.0e-5 ) then
|
---|
95 | call failure(label)
|
---|
96 | write(6,*) 'Got ',a,' expected ', b
|
---|
97 | end if
|
---|
98 | end
|
---|
99 |
|
---|
100 | subroutine c_d(a,b,label)
|
---|
101 | c Check if DOUBLE PRECISION a equals b, and fail otherwise
|
---|
102 | double precision a, b
|
---|
103 | character*(*) label
|
---|
104 | if ( abs(a-b) .gt. 1.0d-5 ) then
|
---|
105 | call failure(label)
|
---|
106 | write(6,*) 'Got ',a,' expected ', b
|
---|
107 | end if
|
---|
108 | end
|
---|