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

How to read always from the first line when using READ in a loop?

  1. Oct 21, 2009 #1
    Hi, folks,
    Here is the code:
    DOUBLE PRECISION X(N),G(N),F,A,d(5000),u(5000)
    open (unit=2, file ="output.txt")
    Do i = 1 , ITER - 1
    Read( 2 , * )
    End Do
    Read( 2 , * ) d(ITER)

    Do i = 1 , n - 1
    Read( 2 , * )
    End Do // it always starts from the next line of last iteration
    How to make it start reading always from the first line for every iteration since in one iteration, maybe this subfunciton will be called several times and I want same data read in one iteration. Any help will be really appreciated. Thanks a lot.

  2. jcsd
  3. Oct 22, 2009 #2


    User Avatar
    Science Advisor

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook