0

I want to read some data from a text file. The name of the file is 'freq.txt' and it is in the same directory where I compiled the code. The text file looks like:

100 cm-1
200 cm-1
300 cm-1

The number of lines may vary. I just want to read the number for further processing. Can anyone help me to do this?

Osman Mamun
  • 2,864
  • 1
  • 16
  • 22

1 Answers1

2
program dataread

integer, parameter :: last=3
real :: dat(last)

open(1,file='freq')
do i=1,last
    read(1,*) dat(i)
    write(*,*) dat(i)
end do
close(1)

end program
Alex
  • 12,078
  • 6
  • 64
  • 74