<Example Program>
Program newunit_example Integer :: unit Open (Newunit=unit,File='DAT',Status='old',Position='Rewind') n_lines = 0 Do Read (unit,'( )',End=10) n_lines = n_lines + 1 End Do 10 Continue Print *,'There are',n_lines,'lines in the file.' Close(unit) End Program |
|
![]() This is line 1 This is line 2 This is line 3; it is longer than the other lines ![]() There are 3 lines in the file. |