Spurious test in gfortran.fortran-torture/execute/intrinsic_mod_ulo.f90
Paul Thomas
paulthomas2@wanadoo.fr
Mon Nov 7 21:02:00 GMT 2005
Whilst trying to develop a faster version of the intrinsic MOD that is
able, at the same time, to handle large ratios between the two
arguments, I was greatly puzzled to find that, at the end of
intrinsic_mod_ulo.f90, is a test:
! Check large numbers
call real4test ((/2e34, 1.0/), (/0.0, 0.0/))
that fails for one candidate MOD and, according to all my other tests,
should fail for the existing version. In fact, MOD (big_number,
divisor) only works sensible for divisor = 1.0. An other choice, gives
results of order 10**34.
I would say, therefore, that this test is spurious because it,
presumably, uses a check in the divide, within the MOD formula, to do
nothing in the case that the divisor is one. That is
mod (x, y) = x - int (x / y) * y Has the unfortunate
property that when x / y exceeds the largest number that can be
represented by the integers available, it saturates the second part of
the expression and the result is of order x. There is a bit of code in
the existingMOD to correct this but it is flawed.
Both rewrites of MOD that I am preparing do better than the existing,
from x/y ~ 10**17 up to 10**19. Beyond this, the fast one gives wild
values, like the present function, whereas the "correct" one is about
20% slower.
Which version would folk like to see?
Paul T
More information about the Fortran
mailing list