From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,e95f364e8526ca2b,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1994-07-11 11:23:12 PST Path: bga.com!news.sprintlink.net!hookup!news.kei.com!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!xlink.net!fauern!news.th-darmstadt.de!rzhp9a.gsi.de!kaspar From: kaspar@rzhp9a.gsi.de (Matthias Kaspar) Newsgroups: comp.sys.dec Subject: Q:Fortran V6.2 query Date: Mon, 11 Jul 94 13:44:53 GMT Organization: GSI, Darmstadt, Germany Distribution: world Message-ID: <1994Jul11.154453@rzhp9a.gsi.de> NNTP-Posting-Host: rzhp9a.gsi.de Keywords: DEC Fortran V6.2-508, OpenVMS AXP, math library, cosd, optimizer 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