program read_file implicit none integer N_LINES, file_unit, line parameter ( N_LINES = 20, file_unit = 10 ) integer i_vec(N_LINES) double precision d_vec(N_LINES) * Open the file named infile open(unit = file_unit, file = 'infile', form = 'formatted', + access = 'sequential', status = 'old') * Read the data do line = 1, N_LINES read(file_unit, *) i_vec(line), d_vec(line) end do * Close the file close(file_unit, status = 'keep') * Print what we just read do line = 1, N_LINES print*, i_vec(line), d_vec(line) end do *------------------------------------------------ * If we don't know the number of lines in he file * we can do like this. Note that i_vec and d_vec * MUST have room for the elements. open(unit = file_unit, file = 'infile', form = 'formatted', + access = 'sequential', status = 'old') line = 1 ! counts the number of lines * end = 100 means: jump to the line with label 100 at end of file do read(file_unit, *, end = 100) i_vec(line), d_vec(line) line = line + 1 end do 100 line = line - 1 ! we did not read anything the last time print*, '# of lines = ', line close(file_unit, status = 'keep') * * Start computing ... * end