# Fortran Help (Do Loop)

1. Feb 11, 2014

### McAfee

Hey guys,

I'm new to fortran and I'm having a slight problem. I put my code below as reference. I first set up a my known values. Then I used an equation to solve for v. After I solve for v I then computed c which involves v.

What I'm now trying to do is to loop the value I got for c back into the equation [c=((r*t)/(p+(a/(v**2))))+b]. So the c would become v and compute a new number.

Any ideas on how I could accomplish that? Thanks for help in advance.

Code (Text):
program homework
open (2, file='output.txt')
a=366*10**3
b=0.0429
p=100
t=300
r=8.3145

DO 1, i=0,5

v=(r*t)/p
c=((r*t)/(p+(a/(v**2))))+b

write(2,*) c

1  continue

end program

2. Feb 11, 2014

### .Scott

First: move the statement "v=(r*t)/p" out of the loop (just before the "do" statement.
Then, after the write statement, add this statement: v=c

That's all it takes.

3. Feb 28, 2014

### selmayda

Hi everyone;
I want to know whether a call statement is used in a do loop. For example;

do 100 ii = 1, 10

call subroutine getsum(ii,20,XX,JJ)

100 continue

Here XX and JJ are parameters.

4. Feb 28, 2014

selmayda,