Fortran FORTRAN Problem Runtime Error: End of File

AI Thread Summary
The discussion centers around a runtime error in Fortran, specifically the "End of File" error encountered while reading data from an input file. The user sought clarification on the error's meaning and assistance in correcting their code, which is intended to read values from a file, count occurrences within a specified interval, and write results to another file for histogram creation. The user was using gfortran on Ubuntu and provided a code snippet highlighting the problematic line. After some troubleshooting, the user resolved the error by removing an unnecessary variable from the read statement. They now seek guidance on ensuring all required data is written to the output file and requested recommendations for debugging resources. Additionally, a suggestion was made to use [CODE] tags for sharing source files to facilitate error tracking.
karenmarie3
Messages
9
Reaction score
0
FORTRAN Problem! "Runtime Error: End of File"

Hey everyone, back again with another Fortran question.

I am getting the runtime error in Fortran "End of Line". I have tried to simply understand what this means, but I am not getting much help from Google.

I have pasted my code below, and highlighted the line that I understand the error exists. (in my terminal window, it's line 32) I am currently working on the latest distro of Ubuntu, and I am compiling with gfortran.

Could someone please assist me in correcting my error, as well as explain to me what this error means, so that I unserstand what to look for in the future? Also, if anyone knows of a good debugging tutorial or website that would be greatly appreciated as well.

This code is designed to read from an input file (x for now, eventually y as well) and count the number of values on an interval then write this data in another file so that I can create a histogram of the data.

If you need further clarification, please let me know.

Thanks in advance!


program histogram

implicit none

integer x_min, x_next, a, N, M
integer y_min, y_next , b, i, j
real x, y, z

real, dimension(4500, 4500, 4500, 4500) :: histo1
integer, dimension(4500, 4500, 4500, 4500) :: histo2

open(unit=2, file="xz.dat", action="read", status="old")
! open(unit=3, file="yz.dat", action="read"' status="old")
open(unit=7, file="xa.dat", action="write"' status="unknown")
! open(unit=8, file="yb.dat", action="write"' status="unknown")


x_min = -13

! y_min = -13

M = 13

N = 4209

do i = -13, M

do j = 1, N

read(2,*) x, z

! read(3,*) y, z

if (x .lt. (x_min + 1)) then

a = a + 1

! if (y .lt. (x_min + 1)) then

! b = b + 1

end if

end do


if (x .lt. (x_min + 1)) then

x_min = x_next

! if (y .lt. (y_min + 1)) then

! y_min = y_next

end if

end do


write(7,*) x, a

! write(8,*) y, b


close(2)
! close(3)
close(7)
! close(8)
stop
end program
 
Technology news on Phys.org
Ok so I solved my runtime error by removing the 'z' in the read line. Now I just need to get the program to write all the data I require to my new file. I'll come back if I have issues with this.
 
When you do, please use the
Code:
 tags to load your source files.  It helps in trying to track down errors.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
5
Views
5K
Replies
17
Views
6K
Replies
19
Views
6K
Replies
12
Views
3K
Replies
2
Views
25K
Replies
5
Views
2K
Replies
3
Views
3K
Back
Top