Reputation: 313
I can't understand why it's happening but it becomes an endless loop when I start the program. What do I do wrong ?
program Hello
REAL K1,K2,RP,G,m,t,time,R1,R2
G = 6.67384 * (10**(-11))
m = 5.9723E24
t = 0.1
RP = 6371000
K1 = 15
K2 = 10
R1 = K1 + RP
R2 = K2 + RP
r = R1
DO WHILE (r > R2)
r = r - ((Gm*t/r**2)*t)
time = time + t
END DO
write (*,*) "Time = seconds"
write (*,*) (Gm*t/r**2)
end program Hello
Upvotes: 2
Views: 76
Reputation: 59999
Gm
is not declared and is implicitly to be real
. The value of Gm
is not set, but it is very likely 0. Therefore r
is the same all the time.
You probably wanted to type G*m
but you have Gm
in ((Gm*t/r**2)*t)
.
Always use implicit none
in your programs. It is VERY important.
And as you found yourself 10**(-11)
is zero, because it is an integer expression. E
or D
must be used for exponent in floating point expressions.
Upvotes: 3