Hello everyone,
I'm a beginner of Fortran95, but with some experience with Fortran77.
In my programming recently, I encounter a problem with READ in Fortran95.
If I read the last line of a data file, the code will report it reaches EOF and disgardes the last number.
For example, This is my program:
OPEN (UNIT=7,FILE='FILNAME.dat')
READ (7,*,end=10) a, b
10 continue
WRITE(*,*) a, b
ENDDO
And this is data file (FILNAME.dat):
100 111
2 1
30 31(EOF)
The program will print like:
100 111
2 1
30 1
I tried to compile this part in Fortran77, and it works fine.
However in Fortran95, it disgards the last record. But unfortunately the whole program has to be compiled in Fortran95.
So is there any method to solve this problem?
Thank you a lot!!!!
I'm a beginner of Fortran95, but with some experience with Fortran77.
In my programming recently, I encounter a problem with READ in Fortran95.
If I read the last line of a data file, the code will report it reaches EOF and disgardes the last number.
For example, This is my program:
OPEN (UNIT=7,FILE='FILNAME.dat')
READ (7,*,end=10) a, b
10 continue
WRITE(*,*) a, b
ENDDO
And this is data file (FILNAME.dat):
100 111
2 1
30 31(EOF)
The program will print like:
100 111
2 1
30 1
I tried to compile this part in Fortran77, and it works fine.
However in Fortran95, it disgards the last record. But unfortunately the whole program has to be compiled in Fortran95.
So is there any method to solve this problem?
Thank you a lot!!!!