I am writing a FORTRAN program that reads data from a text file and writing it to the plato console. the data file looks something like this:
PROGRAM K
IMPLICIT NONE
REAL mark(100),sum
INTEGER n,i
sum=0
OPEN(UNIT=5,FILE='marks1.dat')
READ(5,*)n
if(n<=0)then
close(5)
stop'error:no data'
endif
READ(5,*)(mark(i),i=1,n)
PRINT *, n,' values read as follows:'
PRINT '(8f8.0)', (mark(i),i=1,n)
do i=1,n
sum=sum+mark(i)
END DO
CLOSE(5)
PRINT '(a,F6.2)','The average value is ', sum/n
END PROGRAM K
and my dat file (marks1.dat) is as
10
11
12
12
13
14
15
16
17
18
19
19
20
20
Instead of getting displayed as the same values in the text file, the following is the output
10 values read as follows:
11. 12. 12. 13. 14. 15. 16. 17.
18. 19.
The average value is 14.70
Press RETURN to close window . . . the first and some last data is failed to read.(':!:') please help me,thanks so much.