Reputation: 77
I'm running this code via fortran 90
Program Projectile
! This Program Calculates the Velocity and Height of a
! Projectile
! Given its Initial Height, Initial Velocity and Constant
! Acceleration.
Implicit None
Real :: Initial_Hight, Height, Initial_Velocity, Velocity, &
Time, Acceleration = -9.807
! Obtain Values for Initial Height, Initial Velocity and
! Time
Print*, "Enter the Initial Height and Velocity:"
Read*, Initial_Height, Initial_Velocity
Print*, "Enter Time at Which to Calculate Height and &
Velocity:"
Read*, Time
! Calculate the Height and Velocity
Height = 0.5 * Acceleration * Time ** 2 + Initial_Velocity &
* Time + Initial_Height
Velocity = Acceleration * Time + Initial_Velocity
! Display Velocity and Height
Print*, "At Time", Time, "The Vertical Velocity is", Velocity
Print*, "and the Height is", Height
End Program Projectile
But I constantly get this Error : Error Symbol 'initial_height' has no IMPLICIT type and after erasing implicit none line I can't use real number because real number cause another error, can you help me out?
Upvotes: 1
Views: 44229
Reputation: 9519
You just have a typo in you code here:
Real :: Initial_Hight, Height, Initial_Velocity, Velocity, &
Time, Acceleration = -9.807
Which should read
Real :: Initial_Height, Height, Initial_Velocity, Velocity, &
Time, Acceleration = -9.807
Upvotes: 3
Reputation: 7667
You have two problems.
As Gilles pointed out, you have a typo in your existing code.
Your second problem is that you do not understand the FORTRAN implicit type rule. Variables whose names start with I, J, K, L, M, or N are implicitly INTEGER, unless declared otherwise. All other variables are implicitly REAL, unless declared otherwise.
INITIAL_HEIGHT is implicitly INTEGER, unless you declare it REAL, which you didn't do. You declared INITIAL_HIGHT to be REAL, and you left INITIAL_HEIGHT undeclared. Ordinarily, it would be implicitly made INTEGER, which causes a real assignment to barf. Because you disabled implicit typing altogether, via IMPLICIT NONE, INITIAL_HEIGHT has no type.
And that's what the compiler is trying to tell you.
Upvotes: 14