- #1
Azorio
- 6
- 0
I am trying to read and display the content of a text file in Fotran 90 to make sure that fortran is interpreting the data correctly. Eventually I want to store the data in an array so I can calculate averages, but at the moment I am still working on getting the data displayed in Fortran. I've been at it for a couple hours and cannot figure out the problem. I am getting an end of the file runtime error. Here is the code:
PROGRAM testx
IMPLICIT NONE
CHARACTER(20) :: File Name
INTEGER :: Count = 0, OpenStatus, InputStatus
REAL :: Y, M, D, Rain, Tmax, Tmin, srain, stmax, stmin
WRITE (*, '(1X, A)', ADVANCE = "NO") "Enter name of data file:"
READ *, FileName
OPEN (UNIT = 15, FILE = FileName, STATUS = "OLD")
READ(15,*) Y, M, D, Rain, Tmax, Tmin
100 FORMAT (6x)
PRINT 100, "Year", "Month", "Day", "Rainfall", "MxTemp", "MiTemp"
END PROGRAM testx
Here is the text file containing the data I am working with:
View attachment testx.txt
PROGRAM testx
IMPLICIT NONE
CHARACTER(20) :: File Name
INTEGER :: Count = 0, OpenStatus, InputStatus
REAL :: Y, M, D, Rain, Tmax, Tmin, srain, stmax, stmin
WRITE (*, '(1X, A)', ADVANCE = "NO") "Enter name of data file:"
READ *, FileName
OPEN (UNIT = 15, FILE = FileName, STATUS = "OLD")
READ(15,*) Y, M, D, Rain, Tmax, Tmin
100 FORMAT (6x)
PRINT 100, "Year", "Month", "Day", "Rainfall", "MxTemp", "MiTemp"
END PROGRAM testx
Here is the text file containing the data I am working with:
View attachment testx.txt
Last edited: