tand function compatibility

Questions on using the PGI Compilers and Tools
Post Reply
Henrique Rennó
Posts: 10
Joined: Nov 21 2019

tand function compatibility

Post by Henrique Rennó » Tue Nov 26, 2019 12:56 pm

Hello,

Sorry for asking again about the compatibility between ifort and pgf90, as I did in previous posts about the log function (viewtopic.php?f=4&t=7365) and the power operator (viewtopic.php?f=4&t=7371), but I also found differences in the results returned by the tand function (tangent in degrees). For val1 results match, but for val2 don't.

Please, refer to that posts where I explain why I need the same results even if the differences are so small in one particular calculation.

System: Intel Core i7 7820x, Linux CentOS 7.5.1804
Compilers: Intel Fortran 19.0.5.281 (ifort), PGI Fortran 19.10-0 (pgf90)
Compilation: Intel -> ifort -o tand.ifort tand.f90; PGI -> pgf90 -o tand.pgf90 tand.f90 -tp=px -Kieee

Results:
ifort
val1: -0.19099083542823791504
val2: -0.12464910000562667847
pgf90
val1: -0.19099083542823791504
val2: -0.12464910745620727539

Code: Select all

program calctand

    real :: val1, val2

    val1 = -10.8127498626708984375
    val2 = -7.10521984100341796875

    write(*,'(A,F30.20)') 'val1: ', tand(val1)
    write(*,'(A,F30.20)') 'val2: ', tand(val2)

end program calctand
Is there another flag to make the results match? What is the reason for such discrepancies?

Thanks

mkcolg
Posts: 8137
Joined: Jun 30 2004

Re: tand function compatibility

Post by mkcolg » Wed Nov 27, 2019 10:48 am

Not in this case, but the results do match up to the 7th place which is the most that can be expected when using single precision even with strict IEEE 754 compliance enabled. When using double precision, the results match to the 17th place, so you may consider using double precision if you need more accuracy.

-Mat

Post Reply