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:
    SUBROUTINE CALCFG(N,X,F,G,ITER)
    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.

    Rui.
     
  2. jcsd
  3. Oct 22, 2009 #2

    minger

    User Avatar
    Science Advisor

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to read always from the first line when using READ in a loop?
Loading...