Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran Help (Do Loop)

  1. Feb 11, 2014 #1
    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')

          DO 1, i=0,5


          write(2,*) c
       1  continue
          end program
  2. jcsd
  3. Feb 11, 2014 #2
    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.
  4. Feb 28, 2014 #3
    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.
  5. Feb 28, 2014 #4


    Staff: Mentor

    Please start a new thread with your question. Tacking an unrelated question onto an existing thread is known as "hijacking."
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook