1

I have an external data file which contains several lines with values of parameters. This file is used as input data file for several FORTRAN codes. However, each code does not need all the data. Currently, all codes read the entire data file and keep each one whatever is needed. But, I want to improve this. Each code reads the external data file using the following commands

OPEN(UNIT=10,FILE='input.par',STATUS='UNKNOWN')
READ(10,*)val1
READ(10,*)val2
READ(10,*)val3
..............
READ(10,*)valn
CLOSE(10)

So, how can I OPEN the data file and read, let's say for example, only line 4 or lines 1 and 7?

Many thanks in advance.

1 Answer 1

3

For example, to read just the first and seventh numbers:

read (10, *) val1

do i=1, 5
   read (10, *)
end do

read (10, *) val7
1
  • Thank you very much for your quick and apt response!
    – Vaggelis_Z
    Mar 9, 2013 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.