Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Q:Fortran V6.2 query
@ 1994-07-11 13:44 Matthias Kaspar
  1994-07-11 15:50 ` Steve Lionel
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias Kaspar @ 1994-07-11 13:44 UTC (permalink / raw)


Hi everybody,

A colleague of mine recently experienced some problems with
the cosd() function of the DEC Fortran Compiler V6.2-508 which
has been installed together with OpenVMS 6.1 on our AXP cluster
about three weeks ago. Finally, he came up with a piece of code 
which (slightly modified) looks like this...

        program test

        integer count
        real*4 argument
        do count=1,20
          argument=89.99999+1.0e-06*float(count)
          write(6,*)count,argument,cosd(argument),sind(argument)
        end do
        end


Try to compile this with the default qualifiers.

When count reaches 4, argument comes close to 90.0. 
However, the cosd() call does not return zero, but NaN 
(read: Not a Number) instead.

Now drop the sind(argument) from the write command, 
i.e. change the line to 

	   write(6,*)count,argument,cosd(argument)

and run the program again. Now, when 90. degrees are reached,
the cosd() correctly returns zero.

Am I missing something here or might this be a bug? Why should
the result of the cosd() call depend on whether sind() is
called afterwards or not?

If you drop the do-loop and just set count to 4, cosd() correctly
returns zero whether the sind() is present in the write command
or not. Now what's the difference between count being explicitly
set to 4 or by being incremented step by step and finally reaching 
4 in a do-loop?

Now change the declaration of argument from real*4 to real*8
and cosd() and sind() to dcosd() and dsind() resp. 
dcosd() returns NaN as well. 

Now try real*16, qcosd() and qsind() and....yea! You finally get
zero even though the float() call should return a real*4 value
which is then added to a real*16 value.

Surprisingly, the problem is gone as soon as I compile the code
with the /nooptimize qualifier (looks like an optimizer-bug, 
doesn't it?).

Thanks for taking the time to read all of this, all
comments are welcome.

Bye,

Matthias Kaspar

MKASPAR@AXP601.GSI.DE


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1994-07-11 15:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-07-11 13:44 Q:Fortran V6.2 query Matthias Kaspar
1994-07-11 15:50 ` Steve Lionel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox