Fortran90 problem, runtime error

In summary, the conversation discusses an error that occurs when running a code, and the possibility that it may be caused by the position of an open file. The code also includes instructions for turning off implicit typing and opening, writing, and reading from a file. The possibility of the error being caused by simultaneous writing and reading is also mentioned.
  • #1
Saxby
45
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
  • #2
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.
 

1. What is a Fortran90 runtime error?

A Fortran90 runtime error is an error that occurs during the execution of a program written in the Fortran90 programming language. It typically indicates that there is an issue with the code that is preventing the program from running correctly.

2. What causes Fortran90 runtime errors?

Fortran90 runtime errors can be caused by a variety of factors, such as syntax errors, logical errors, or incorrect use of variables. They can also occur due to issues with the compiler or system resources.

3. How can I debug a Fortran90 runtime error?

To debug a Fortran90 runtime error, you can use a debugger tool or add debugging statements to your code. These tools can help you identify the specific line of code that is causing the error and provide more information about the error itself.

4. How do I fix a Fortran90 runtime error?

The best way to fix a Fortran90 runtime error is to carefully review your code and identify the source of the error. Once you have identified the issue, you can make the necessary changes to your code to resolve the error. It may also be helpful to consult with other Fortran90 programmers or refer to online resources for guidance.

5. Are there any common Fortran90 runtime errors?

Yes, there are some common Fortran90 runtime errors that programmers may encounter. These include out-of-bounds errors, undefined variable errors, and arithmetic errors. However, the specific errors you encounter will depend on your code and its unique characteristics.

Similar threads

  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
4
Views
621
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
2
Views
7K
  • Programming and Computer Science
Replies
2
Views
8K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
Back
Top