- #1
fluidistic
Gold Member
- 3,923
- 261
Here's a part of my program in which I'm having an error while compiling:
I'm having the error with gfortran: "Fortran runtime error: End of file" for the line "read(1,*)x(i), y(i)".
Basically if I enter n=5, my program opens a file, write in it 6 values for x and 6 values for f. I want my program to read them and to assignate the first value of x to x(0), the first value of f to y(0); the second value of x: x(1), second value of f: y(1), etc.
I've opened my file "tabla.dat" and it looks like this:
which seems ok since to me (well maybe not numerically but at least its form looks ok to me).
Any idea what's wrong/going on?
Thanks in advance.
Code:
open(unit=1,file="tabla.dat")
allocate (x(n),y(n),f(n))
do i=0,n
x=(2*i)/n-1
f=1/(1+25*x**2)
write(1,*)x,f
end do
do i=0,n
read(1,*)x(i), y(i)
end do
close(1)
Basically if I enter n=5, my program opens a file, write in it 6 values for x and 6 values for f. I want my program to read them and to assignate the first value of x to x(0), the first value of f to y(0); the second value of x: x(1), second value of f: y(1), etc.
I've opened my file "tabla.dat" and it looks like this:
Code:
-1.0000000 -1.0000000 -1.0000000 3.84615399E-02 3.84615399E-02 3.84615399E-02
-1.0000000 -1.0000000 -1.0000000 3.84615399E-02 3.84615399E-02 3.84615399E-02
0.0000000 0.0000000 0.0000000 1.0000000 1.0000000 1.0000000
1.0000000 1.0000000 1.0000000 3.84615399E-02 3.84615399E-02 3.84615399E-02
Any idea what's wrong/going on?
Thanks in advance.