On 9/11/26 22:37, Steve Kargl wrote:
With -O3, I get
% gfcx -o z -O3 bessel.f90 -fdump-tree-optimized && ./z
0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
which is not at all what I expected! In fact, if I look for symbols in
z there is no call to j0f in the math library.
So, if I wrap bessel_j0(x) in a module in a separate file,
% cat myj0.f90
module j0m
implicit none
contains
elemental function myj0(x) result(r)
real(4) r
real(4), intent(in) :: x
r = bessel_j0(x)
end function myj0
end module j0m
% cat bessel1.f90
program besseltest
use j0m
implicit none
integer i
integer n(10)
real(4) x(10), e(10), f(10)
e = [ &
& 5.64343985e-8, 2.44766589e-8, 1.03553056e-7, -3.53017149e-9, &
& -6.48150511e-9, 5.15323162e-9, -1.50233475e-7, 1.25245705e-7, &
& 5.43311032e-8, 1.22055454e-7]
x = [ 2.40482556, 5.52007811, 8.65372791, 11.7915344, 14.9309177, &
& 18.0710640, 21.2116366, 24.3524715, 27.4934791, 30.6346065]
f = myj0(x)
n = exponent(e);
f = abs(e - f);
f = scale(f, 24 - n);
print '(*(F0.0,1x))', f;
end program besseltest
I get
% gfcx -c -O3 myj0.f90
% gfcx -o z -O3 bessel.f90 myj0.o && ./z
900691. 182038. 6333. 48537. 203435. 364229. 14664. 5813. 18993. 1306.
I have no idea what -O3 is doing with original testcase.
--
steve