Fortran on X86 : SQRT with complex argument is wrong

Post Reply

Topic author
joukj
Master
Posts: 175
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

Fortran on X86 : SQRT with complex argument is wrong

Post by joukj » Tue Jun 13, 2023 6:23 am

Hi All,

I get this:

Code: Select all

rumba-jj) ty test.f90
program test
  complex*16 x
  complex*8 y
  complex z
  x = (1.0,0.0)
  y = (1.0,0.0)
  z = (1.0,0.0)
  write(*,*) sqrt( x ) , sqrt( y ) , sqrt( z )
end
  13-JUN-2023 12:19:10
rumba-jj) f90/noop test.f90
rumba-jj) link test
rumba-jj) run test
(0.000000000000000E+000,2.00000000000000) (1.000000,2.000000)
(1.000000,2.000000)
rumba-jj) f90/vers
VSI Fortran X8.5-0002 (GEM 50X2N) for X86 systems
rumba-jj) 
The answer should be (1.0,0) in all three cases.

Added in 40 minutes 25 seconds:
I tried to rewrite the sqrt function using the exp function, but that one seems to crash. (try to run the above sample where sqrt is replaced by exp)

Added in 1 hour 5 minutes 49 seconds:
Looks like the sin and cos functions on complex arguments are also giving wrong results or crash.


jreagan
VSI Expert
Master
Posts: 139
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: Fortran on X86 : SQRT with complex argument is wrong

Post by jreagan » Wed Jun 14, 2023 10:22 am

Some of these we have already fixed. COMPLEX*4 should work now but COMPLEX*8 and COMPLEX*16 is a work in progress. The release notes should say that. The issue is with out the values return from the SQRT math routines. On Alpha and Itanium, return values larger than 64 bits are passed via a hidden 1st argument. On x86, that is now 128 bits or larger. There is a mismatch between the cross-compiler used to build the Math RTL on the system and the native compiler.

We are trying to get refreshed compilers on the support portal this week or next week.


Topic author
joukj
Master
Posts: 175
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

Re: Fortran on X86 : SQRT with complex argument is wrong

Post by joukj » Thu Jun 15, 2023 2:45 am

What is complex*4??? my compiler does not accept it.l


jreagan
VSI Expert
Master
Posts: 139
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: Fortran on X86 : SQRT with complex argument is wrong

Post by jreagan » Thu Jun 15, 2023 9:49 pm

Again, my confusion with COMPLEX(KIND=4)

Post Reply