 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
dgurok
Joined: 26 May 2011 Posts: 66
|
Posted: Wed Jun 01, 2011 10:52 am Post subject: different results: ftn77->ftn95 |
|
|
Hello everybody,
I encountered problems whereever integer was used in instrinsic functions of typ real. this strange behavior is different compared to ftn77.
Isn�t the data type of an expression defined by the hightest order from left to right any more?
Results with ftn77
Code: |
14.14214 integer 2 exponent in subroutine
14.14214 IV4 as exponent
14.14214 IV2 as exponent
14.14214 2 as exponent - not using /INTS compile option
14.14214 2.0 as exponent
14.14214 2 as exponent for negative argument - not using /INTS |
Results with ftn95
Code: |
10.00000 integer 2 exponent in subroutine
14.14214 IV4 as exponent
10.04988 IV2 as exponent
14.14214 2 as exponent - not using /INTS compile option
14.14214 2.0 as exponent
14.14214 2 as exponent for negative argument - not using /INTS |
Source Code:
Code: | C
C Salford FTN95 evaluation
C Compile Option: set ftn95opt=/C/DEBUG/ALL_WARNINGS/UNLIMITED_ERRORS/FIXED_FORMAT/WINDOWS
C
integer*2 IV2
integer*4 IV4
real*4 x2,x4,y2,y4,W42
real*4 SQRT
x4=10.
x2=0.
y4=10.
y2=0.
call sr1(.true.,2s,x2,x4,y2,y4)
iv2=2
iv4=2
C
C Result is 0.0 due to exponent as integer
W42=SQRT((X4-X2)**IV4 +(Y4-Y2)**IV4 )
write(2,1001) w42, ' IV4 as exponent'
C
C Result is 0.0 due to exponent as integer
W42=SQRT((X4-X2)**IV2 +(Y4-Y2)**IV2 )
write(2,1001) w42, ' IV2 as exponent'
C
C Result is wrong due to exponent as integer
W42=SQRT((X4-X2)**2 +(Y4-Y2)**2 )
write(2,1001) w42,
* ' 2 as exponent - not using /INTS compile option'
C
C Proper result due to **2.0
W42=SQRT((X4-X2)**2.0+(Y4-Y2)**2.0)
write(2,1001) w42, ' 2.0 as exponent '
C
C Result invalid due to negativ value of x2-x4
W42=SQRT((X2-X4)**2 +(Y4-Y2)**2 )
write(2,1001) w42,
* ' 2 as exponent for negative argument - not using /INTS'
C
C Result invalid due to negativ value of x2-x4
C W42=SQRT((X2-X4)**2. +(Y4-Y2)**2. )
C write(2,1001) w42
1001 format(F10.5,A)
end
subroutine SR1(LOGIC,i2,x2,x4,y2,y4)
integer*2 I2
logical*4 logic
real*4 x2,x4,y2,y4
W42=SQRT((X4-X2)**i2 +(Y4-Y2)**i2 )
write(2,1001) w42,' integer 2 exponent in subroutine'
if(logic) return
return
1001 format(F10.5,A)
end |
|
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Thu Jun 02, 2011 3:21 am Post subject: |
|
|
I changed the program slightly to free format and compiled and ran with
/ints /lgo or /intl /lgo to get significantly different results.
Code: | !
integer*2 IV2
integer*4 IV4
real*4 x2,x4,y2,y4,W42
! real*4 SQRT
x4=10.
x2=0.
y4=10.
y2=0.
call sr1(.true.,2s,x2,x4,y2,y4)
iv2=2
iv4=2
!
write (2,*) '(X4-X2)**IV2 +(Y4-Y2)**IV2 = ', (X4-X2)**IV2 + (Y4-Y2)**IV2
write (2,*) '(X4-X2)**IV4 +(Y4-Y2)**IV4 = ', (X4-X2)**IV4 + (Y4-Y2)**IV4
!
! Result is 0.0 due to exponent as integer
W42=SQRT((X4-X2)**IV4 +(Y4-Y2)**IV4 )
write(2,1001) w42, ' IV4 as exponent'
!
! Result is 0.0 due to exponent as integer
W42=SQRT((X4-X2)**IV2 +(Y4-Y2)**IV2 )
write(2,1001) w42, ' IV2 as exponent'
!
! Result is wrong due to exponent as integer
W42=SQRT((X4-X2)**2 +(Y4-Y2)**2 )
write(2,1001) w42, ' 2 as exponent - not using /INTS compile option'
!
! Proper result due to **2.0
W42=SQRT((X4-X2)**2.0+(Y4-Y2)**2.0)
write(2,1001) w42, ' 2.0 as exponent '
!
! Result invalid due to negativ value of x2-x4
W42=SQRT((X2-X4)**2 +(Y4-Y2)**2 )
write(2,1001) w42, ' 2 as exponent for negative argument - not using /INTS'
!
! Result invalid due to negativ value of x2-x4
! W42=SQRT((X2-X4)**2. +(Y4-Y2)**2. )
! write(2,1001) w42
1001 format(F10.5,A)
end
subroutine SR1(LOGIC,i2,x2,x4,y2,y4)
integer*2 I2
logical*4 logic
real*4 x2,x4,y2,y4, w42
W42=SQRT((X4-X2)**i2 +(Y4-Y2)**i2 )
write(2,1001) w42,' integer 2 exponent in subroutine'
if(logic) return
return
1001 format(F10.5,A)
end
|
/ints /lgo produces Code: | [FTN95/Win32 Ver. 5.50.0 Copyright (c) Silverfrost Ltd 1993-2010]
NO ERRORS [<main program> FTN95/Win32 v5.50.0]
NO ERRORS [<SR1> FTN95/Win32 v5.50.0]
Creating executable: C:\TEMP\lgotemp@.exe
Program entered
10.00000 integer 2 exponent in subroutine
(X4-X2)**IV2 +(Y4-Y2)**IV2 = 200.000
(X4-X2)**IV4 +(Y4-Y2)**IV4 = 200.000
14.14214 IV4 as exponent
10.04988 IV2 as exponent
10.00500 2 as exponent - not using /INTS compile option
14.14214 2.0 as exponent
0.94868 2 as exponent for negative argument - not using /INTS
|
/intl /lgo produces Code: | [FTN95/Win32 Ver. 5.50.0 Copyright (c) Silverfrost Ltd 1993-2010]
NO ERRORS [<main program> FTN95/Win32 v5.50.0]
NO ERRORS [<SR1> FTN95/Win32 v5.50.0]
Creating executable: C:\TEMP\lgotemp@.exe
Program entered
10.00000 integer 2 exponent in subroutine
(X4-X2)**IV2 +(Y4-Y2)**IV2 = 200.000
(X4-X2)**IV4 +(Y4-Y2)**IV4 = 200.000
14.14214 IV4 as exponent
1.04881 IV2 as exponent
14.14214 2 as exponent - not using /INTS compile option
14.14214 2.0 as exponent
14.14214 2 as exponent for negative argument - not using /INTS
|
|
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Thu Jun 02, 2011 6:29 am Post subject: |
|
|
Definately a problem in FTN95 if the expression inside SQRT uses integer*2 for exponent.
Code: | integer*2 IV2
integer*4 IV4
real*4 x2,x4,y2,y4,W42, x
! real*4 SQRT
intrinsic sqrt
!
x4=10.
x2=0.
y4=10.
y2=0.
call sr1(.true.,2s,x2,x4,y2,y4)
call sr1(.true.,2_2,x2,x4,y2,y4)
call sr1(.true.,2_3,x2,x4,y2,y4)
!
iv2=2
iv4=2
!
write (2,*) '(X4-X2)**IV2 +(Y4-Y2)**IV2 = ', (X4-X2)**IV2 + (Y4-Y2)**IV2
write (2,*) '(X4-X2)**IV4 +(Y4-Y2)**IV4 = ', (X4-X2)**IV4 + (Y4-Y2)**IV4
!
! Result is 0.0 due to exponent as integer
W42=SQRT((X4-X2)**IV4 +(Y4-Y2)**IV4 )
x = ((X4-X2)**IV4 +(Y4-Y2)**IV4 )
write(2,1001) w42, ' IV4 as exponent', x
!
! Result is 0.0 due to exponent as integer
W42=SQRT((X4-X2)**IV2 +(Y4-Y2)**IV2 )
x = ((X4-X2)**IV2 +(Y4-Y2)**IV2 )
write(2,1001) w42, ' IV2 as exponent', x
!
! Result is wrong due to exponent as integer
W42=SQRT((X4-X2)**2 +(Y4-Y2)**2 )
x = ((X4-X2)**2 +(Y4-Y2)**2 )
write(2,1001) w42, ' 2 as exponent - not using /INTS compile option', x
!
! Proper result due to **2.0
W42=SQRT((X4-X2)**2.0+(Y4-Y2)**2.0)
x = ((X4-X2)**2.0+(Y4-Y2)**2.0)
write(2,1001) w42, ' 2.0 as exponent ', x
!
! Result invalid due to negativ value of x2-x4
W42=SQRT((X2-X4)**2 +(Y4-Y2)**2 )
x = ((X2-X4)**2 +(Y4-Y2)**2 )
write(2,1001) w42, ' 2 as exponent for negative argument - not using /INTS', x
!
1001 format(F10.5,A,f10.5)
end
subroutine SR1(LOGIC,i2,x2,x4,y2,y4)
!
integer*2 I2
logical*4 logic
real*4 x2,x4,y2,y4, w42, x, y
intrinsic sqrt
!
W42=SQRT((X4-X2)**i2 + (Y4-Y2)**i2 )
x = ((X4-X2)**i2 + (Y4-Y2)**i2 )
y =SQRT(x)
write(2,1001) w42,' integer 2 exponent in subroutine', x,y
if(logic) return
return
1001 format(F10.5,A,2f10.5)
end
|
results of runs Code: | using /intl /lgo
[FTN95/Win32 Ver. 5.50.0 Copyright (c) Silverfrost Ltd 1993-2010]
Creating executable: C:\TEMP\lgotemp@.exe
Program entered
10.00000 integer 2 exponent in subroutine 200.00000 14.14214
...
14.14214 IV4 as exponent 200.00000
10.04988 IV2 as exponent 200.00000
14.14214 2 as exponent - not using /INTS compile option 200.00000
14.14214 2.0 as exponent 200.00000
14.14214 2 as exponent for negative argument - not using /INTS 200.00000
using /ints /lgo
[FTN95/Win32 Ver. 5.50.0 Copyright (c) Silverfrost Ltd 1993-2010]
Creating executable: C:\TEMP\lgotemp@.exe
Program entered
10.00000 integer 2 exponent in subroutine 200.00000 14.14214
...
14.14214 IV4 as exponent 200.00000
10.00500 IV2 as exponent 200.00000
1.04881 2 as exponent - not using /INTS compile option 200.00000
14.14214 2.0 as exponent 200.00000
0.94868 2 as exponent for negative argument - not using /INTS 200.00000
|
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Wed Mar 07, 2012 10:32 am Post subject: |
|
|
This bug has now been fixed for the next release of FTN95. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|