- #1
Ashiley
- 1
- 0
Hello, every one:
I have a piece of data like this:
1999 1 1 0.0 1 1.0000000e+00 -9.9900000e+02 4.8646021e-01 0
1999 1 1 0.5 1 1.0208334e+00 -9.9900000e+02 4.9180925e-01 0
1999 1 1 1.0 1 1.0416666e+00 -9.9900000e+02 3.7898308e-01 0
1999 1 1 1.5 1 1.0625000e+00 -9.9900000e+02 3.5607040e-01 0
The first three column are integers, as well as the fifth (three digits) and the last one (one digit). I put them into a data file: x.dat and tried to read them in and output to another data file: y.dat, in which there is a comma between two columns.
I used the following code but got error:
INTEGER A(4), B(4), C(4), D(4), E(4)
REAL F(4)
DOUBLE PRECISION S1(4), S2(4), S3(4)
OPEN (66, FILE = 'x.dat', STATUS = 'OLD')
OPEN (9, FILE = 'y.dat', STATUS = 'NEW')
READ (66, 20) A(1), B(1), C(1), F(1), D(1), S1(1), S2(1), S3(1), E(1)
20 FORMAT(I4, I2, I2, F4.1, I3, 3E13.7, I1)
WRITE(9, 30) S1(1), S2(1), S3(1)
30 FORMAT(3(E13.7, ','))
I didn't read all data in but the first row and I have error message:
"writing sequential formatted external I0"
"Aborted"
Could some one here point out my mistakes? Thank you!
Ashiley
I have a piece of data like this:
1999 1 1 0.0 1 1.0000000e+00 -9.9900000e+02 4.8646021e-01 0
1999 1 1 0.5 1 1.0208334e+00 -9.9900000e+02 4.9180925e-01 0
1999 1 1 1.0 1 1.0416666e+00 -9.9900000e+02 3.7898308e-01 0
1999 1 1 1.5 1 1.0625000e+00 -9.9900000e+02 3.5607040e-01 0
The first three column are integers, as well as the fifth (three digits) and the last one (one digit). I put them into a data file: x.dat and tried to read them in and output to another data file: y.dat, in which there is a comma between two columns.
I used the following code but got error:
INTEGER A(4), B(4), C(4), D(4), E(4)
REAL F(4)
DOUBLE PRECISION S1(4), S2(4), S3(4)
OPEN (66, FILE = 'x.dat', STATUS = 'OLD')
OPEN (9, FILE = 'y.dat', STATUS = 'NEW')
READ (66, 20) A(1), B(1), C(1), F(1), D(1), S1(1), S2(1), S3(1), E(1)
20 FORMAT(I4, I2, I2, F4.1, I3, 3E13.7, I1)
WRITE(9, 30) S1(1), S2(1), S3(1)
30 FORMAT(3(E13.7, ','))
I didn't read all data in but the first row and I have error message:
"writing sequential formatted external I0"
"Aborted"
Could some one here point out my mistakes? Thank you!
Ashiley