- #1
eth
- 3
- 0
Hello,
I'm pretty new to fortran95 and I've run into a stuck point extracting data from a file, here's what's up:
I have a file test.dat that has 2 columns and variable number of rows (different experiments will yield different amounts of points). I want to put the data into a matrix of equivalent dimensions as the file, if possible. My main issue is that since I won't be able to know the number of rows in the datafile, the "read" command crashes the program at the end of the file-reading.
datafile looks like this, with around 50000 rows:
The fortran code I have right now looks like:
I think I'm in need of a command that finds how many rows are in the textfile
help please! Thanks!
I'm pretty new to fortran95 and I've run into a stuck point extracting data from a file, here's what's up:
I have a file test.dat that has 2 columns and variable number of rows (different experiments will yield different amounts of points). I want to put the data into a matrix of equivalent dimensions as the file, if possible. My main issue is that since I won't be able to know the number of rows in the datafile, the "read" command crashes the program at the end of the file-reading.
datafile looks like this, with around 50000 rows:
Code:
2 14.2000
1 17.9000
1 27.7000
2 28.8000
1 44.3500
2 43.5000
2 58.2500
1 58.3500
1 72.6700
2 72.6500
The fortran code I have right now looks like:
Code:
double precision datamatrix(200000,2)
open(unit=9,file='data/test.dat')
read(9,901) datamatrix
901 format(F10.4,F10.4)
I think I'm in need of a command that finds how many rows are in the textfile
help please! Thanks!