Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: lionel@quark.enet.dec.com (Steve Lionel)
Subject: Re: Q:Fortran V6.2 query
Date: 11 Jul 1994 15:50:37 GMT	[thread overview]
Message-ID: <2vrpod$s3l@jac.zko.dec.com> (raw)
In-Reply-To: 1994Jul11.154453@rzhp9a.gsi.de


In article <1994Jul11.154453@rzhp9a.gsi.de>, kaspar@rzhp9a.gsi.de 
(Matthias Kaspar) writes:
|>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?).

No, it's not.  It's a Run-Time Library bug in OpenVMS AXP V6.1.  The reason it 
matters whether or not you also call sind is that the compiler uses an 
optimized entry point that computes both the sin and cos in a single call.  
This routine has a bug in in when the argument is 90.0.

If you contact your Digital software support center, they will get you a
correction as soon as it is available.  In the meantime, use /NOOPT as
a workaround.
-- 

Steve Lionel                      Mail: lionel@quark.enet.dec.com
DEC Fortran Development           WWW:  http://www.digital.com/info/slionel.html
Digital Equipment Corporation     
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698             "Free advice is worth every cent"

For a summary of Digital's Internet services, send mail to info@digital.com


      reply	other threads:[~1994-07-11 15:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-07-11 13:44 Q:Fortran V6.2 query Matthias Kaspar
1994-07-11 15:50 ` Steve Lionel [this message]
read-only archive

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