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

  • Thread starter Thread starter sky01237
  • Start date Start date
  • Tags Tags
    Line Loop
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 5K views
sky01237
Messages
1
Reaction score
0
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.
 
Physics news on Phys.org