caspar@wn2.sci.kun.nl (Caspar Terheggen) (11/01/89)
I would like to thank everyone who responded to my article about real -> double complex conversion. Since one of them asked me to summarize to the net and this might be interesting for others as well, here goes: In my previous article I mentioned that in Fortran 77 complex*16 z z = 1.0/1.0 would give a wrong result on our Sun4, i.e. z wasn't equal to one. The problem is caused by a bug in version 1.1 of the Sun f77 compiler. Several people told me that it is fixed in version 1.2. Examining the assembly code generated by the compiler Dan Mick narrowed the problem down to a call to Ff_conv_z. According to Dan this routine starts with a SPARC fitod instruction, which translates from *integer* to double precision floating point. Obviously this causes the conversion to fail. Thank to Michael M. Fischbein and Daniel Ehrlich I found out which version of f77 we have by looking at /usr/lib/lang_info (I didn't know about this file). Roland Schneider and Dik Winter (many thanks) suggested a (temporary) fix, which seems to work fine. Roland writes: | ... and they [Sun] suggested using inline floating point (hang | "/usr/lib/libm.il" on the end of your COMPILE command. This fixes the | problem by avoiding a call to the conversion routine in the library. | This is documented in the floating point programmers guide. I find this 'fix' particularly useful, because it avoids the need to find and change any source that might depend on implicit conversion. Still, updating to the new version of the compiler and/or inserting explicit conversion routines like CMPLX() (as Adam Mirowski suggested in his article) may be more secure. Also a few people mentioned that complex*16, both the existence and notation, isn't standard Fortran 77, but is part of Sun's extension. Regards, Caspar Terheggen +31 80 612800 caspar@sci.kun.nl U634008@HNYKUN11.EARN