1

I am writing a program in Fortran to find the velocity of a parachuting person in relation to time. I keep getting an error that I can't fix. I am very new to programming and any help is greatly appreciated.

The error is

v(i+1)=v(i)+[32-((c*v(i)*v(i))/m)]*(h)
1

Error: Incompatible ranks 0 and 1 in assignment at (1)

and my program is

PROGRAM para
INTEGER :: i
REAL :: v(11) !velocity
REAL :: q !initial velocity
REAL :: h !time step
REAL :: c !drag coefficient
REAL :: m !mass

! gravity is equal to 32 ft/s^2

WRITE (*,*)'enter time step'
READ(*,*)h

Write(*,*)'enter initial velocity'
READ(*,*)q

WRITE(*,*)'enter drag coefficient'
READ(*,*)c

WRITE(*,*)'enter mass'
READ(*,*)m

DO i=1,10 ! from 1 to 10, with 1 being the interval.
END DO

v(i+1)=v(i)+[32-((c*v(i)*v(i))/m)]*(h)

q=v(1)

END PROGRAM

2 Answers 2

3

You cannot use [] as a normal parenthesis in expressions. It is an array constructor, [ items ] means an array with items as elements. Also the end do should be after this line.

0
2

Well, you span up a vector using [ ... ] (this is equivalent to (/ ... /)). So, using regular brackets instead of the square ones solves your problem.

BTW: I'm a little confused about your loop... Shouldn't the v(i+1) = ... line be inside the loop?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.