Fortran Fortran90 problem, runtime error

AI Thread Summary
The discussion centers on a Fortran program encountering a runtime error indicating "End of file" at line 11. The issue arises from attempting to read from a file while simultaneously writing to it, which can lead to complications. Participants suggest ensuring the file exists and recommend using the option FORM='FORMATTED' when opening the file to avoid potential issues with file handling. The code structure and the order of operations in file I/O are highlighted as critical factors in resolving the error.
Saxby
Messages
45
Reaction score
0
Hello, I've been playing around with some code (as shown below) and for some reason everytime i run this code I am told:

At line 11 of file tester.f90
Fortran runtime error: End of file

I'm not really sure what's causing it, is it the position of my Open file?
Any help would be much aprrieiated :)

PROGRAM tester

!Turn off implicit typing
IMPLICIT NONE

INTEGER :: a, b

OPEN(10,FILE='tester.out')

WRITE(10,*) 'Please give value for a'
READ(10,*) a

IF (a < 0) THEN
WRITE(10,*) 'Wrong number'
STOP
END IF

WRITE(10,*) 'Please give value for b'
READ(10,*) b

IF (b > 0) THEN
WRITE(10,*) 'Wrong number'
STOP
END IF

WRITE(10,*) a * b

CLOSE(10)

END PROGRAM tester
 
Technology news on Phys.org
Are you sure the file exists?

You are writing to the file and reading from it simultaneously. This can cause problems if not done carefully.

When opening the file, FORM ='FORMATTED' should probably be used.
 
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...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
5
Views
5K
Replies
17
Views
6K
Replies
9
Views
2K
Replies
6
Views
3K
Replies
2
Views
9K
Replies
4
Views
2K
Back
Top