- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following source code runs fine as far as the PRINT statements go -
But I get completely wrong values when I put a break point after the PRINT statements, and
try to look at the variable contents. It looks like it does not think they were initialized.
And about half the time VS crashes ! !
The problem goes away when I make everything real(8) instead.
program kepler
implicit none
real(16) r(3),th(3),x(3),y(3),e,p,kang
!!!!!!!!!!!!!!!!!!!!!
kang=1
e=0.
p=1.0
th(1)=.7854Q0
r(1) =p/( 1.0 - e*cos(th(1)) )
th(2)=kang/r(1)**2 ! theta dot
r(2) =-sin(th(1))/( 1.0 - e*cos(th(1))**2 )
r(2) =r(2)*p
x(1)=r(1)*cos(th(1))
y(1)=r(1)*sin(th(1))
x(2)=-r(1)*sin(th(1))*th(2)+cos(th(1))*r(2)
y(2)= r(1)*cos(th(1))*th(2)-sin(th(1))*r(2)
th(3)=-2.0*r(2)/r(1)**3
print *,"e,p=",e,p
print *,"r=",r
print *,"th=",th
print *,"x=",x
print *,"y=",y
read(*,*)
end program kepler
Real(16) is part of the standard, right ?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, real(16) is not "part of the standard" in that the standard does not specify particular kind numbers. Furthermore, the standard requires only single and double precision. That said, this program should work ok.
I can reproduce an issue with Visual Studio crashing when one hits the breakpoint. It might be that the debug support for REAL(16) has some issues - I'll investigate further.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Something that looks a little strange to me is that you feel you need the precision of REAL(16) in your calculations, but you are using a value for pi/4 that is rounded at the 4th significant digit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not trying to be exact about that, just trying to get approx. 45 degree polar angle.
If I wanted pi/4, I would put the whole thing in to 18 places, then divide it by four.
3.14159265358979323846, etc.
Or say atan(1.0)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried with VS2013+IFort 16.0.1. I did not notice anything unusual in the debugger, after reaching a breakpoint set on the READ statement. All the variables had reasonable values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I could reproduce this with 16.0.0 but not 16.0.2. Please install the current version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, when did 16.0.2 come out ?
I might already have it on the other PC -- -
No big deal, but thought you'd want to be apprised anyway.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Last week.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page