[comp.lang.fortran] Cray amod bug

naparst@cartan.UUCP (11/01/87)

> 	Cray II CFT77 Fortran amod function appears to give seriously wrong
> results on certain occasions. It is possible the other Cray Fortran compiler
> uses the same amod assembly level code; perhaps even the C and Pascal
> compilers.
> 	It sometimes returns -epsilon instead of the Y-epsilon as shown in
> the following:
> 
             [ program deleted to save space] 
> 
> I am alternating between amusement, bewilderment,
> and rage about such a cavalier attitude. IF X < Y BY ANY REPRESENTABLE
> AMOUNT, THE R=AMOD(X,Y) MUST BE NEAR X NOT NEAR 0. 

The author is absolutely correct.  I have verified this bug on our Cray X-MP,
with both the CFT and CFT77 compilers.  This is definitely a hardware bug,
not just in the author's machine, but in all CRAY systems.  I have reported 
this to our systems staff here.  In some sense, this message should not
have been posted to comp.lang.fortran, since it is a hardware problem,
not a compiler problem.  But I don't care about these things.

Cray systems are renowned for their inaccuracies.  You might try dividing
240.0 by 3.0.  I believe you don't get exactly 80.  The author should obtain
a copy of Prof. William Kahan's program "Paranoia" from netlib@anl-mcs.arpa
and run it on the CRAY.  It fails miserably.  On the other hand, if you 
run it on a SUN, you will find complete conformance to the IEEE standard.

Harold Naparst  (naparst@cartan.berkeley.edu)
-- 
Harold Naparst (415)-848-4560
  UUCP		{tektronix,dual,sun,ihnp4,decvax}!ucbvax!cartan!naparst
  New style	naparst@cartan.berkeley.edu	
  ARPA | CSNET	naparst%cartan@berkeley.ARPA

cik@l.cc.purdue.edu (Herman Rubin) (11/02/87)

This problem is not a FORTRAN problem.  The CRAYs have no divide instruction,
but the compiler assumes that it does.  It takes many instructions to assure
that the quotient is "correct" in the sense that problems about sign of the
remainder do not occur.  I suggest that the AMOD code be rewritten to take
the problem into account.

-- 
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907
Phone: (317)494-6054
hrubin@l.cc.purdue.edu (ARPA or UUCP) or hrubin@purccvm.bitnet