Problem converting float -> double complex in f77

Adam MIROWSKI MIROWSKI%FRECP12.BITNET at cunyvm.cuny.edu
Mon Oct 23 05:51:23 AEST 1989


Caspar Terheggen writes about incoherencies in the way f77 treats
complex numbers:
|From:    caspar at wn2.sci.kun.nl (Caspar Terheggen)
|Subject: Problem converting float -> double complex
|
|.....
|Script started on Thu Oct 12 09:30:00 1989
|% more try.f
|      complex*16 z1,z2
|      z1 = 1.0
|      z2 = 1.0/1.0
|      write(*,*) z1,z2
|      end
|% make try
|f77   -sun4 -o try try.f
|try.f:
| MAIN:
|% try
|  (    1.0000000000000,  0.)  (    25.968750000000,  0.)
|% exit
|script done on Thu Oct 12 09:30:20 1989
|
|Why did the conversion to complex*16 go right in one case and wrong in the
|other? I would expect that in both cases a real*4 must be converted to
|complex*16. I am running SunOS 4.0.3_Export #1 on a Sun4. As for the
|compiler: strings /usr/bin/f77 gives (among others) @(#)compile.c 1.70
|88/04/18 SMI.  Any help (e-mail or followup) is appreciated. Thanks in
|advance.

I've studied the question and got following results:
-- FORTRAN 77 doesn't have double precision complex numbers
-- In FORTRAN 77 "*number" can only be appended to CHARACTER
-- By consequence, we are talking about Sun extensions to the standard
-- I have the same results on a Sun4 with the release 3.2EXPORT of
   the system. 'strings /usr/bin/f77 | grep "@(#)"' gives no
   "compile.c" module and the latest date is 87/10/16.
-- The FORTRAN code gives good results on a Sun3 (3.5EXPORT).
   'strings /usr/bin/f77 | grep "@(#)"' gives no "compile.c" module
   and the dates equal to 86/10/07.
-- The code gives good results on MicroSoft FORTRAN Compiler version
   4.01

My impression is that we face a bug in the f77.  My solution is to insert
explicit conversions by CMPLX().  It COULD help, because it helps in the
example above.

Adam Mirowski



More information about the Comp.sys.sun mailing list