PDA

View Full Version : How to read always from the first line when using READ in a loop?


sky01237
Oct21-09, 08:44 PM
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.

minger
Oct22-09, 08:53 AM
I think you need to clarify a little, I'm pretty lost. Perhaps you could use the REWIND statement?
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlf101a.doc/xlflr/rewind.htm