Associate
- Joined
- 6 Nov 2006
- Posts
- 722
- Location
- Devon
Hi,
I have some data files that I am trying to read into Fortran but I can't seem to get it to work. I have the data both as text and binary files but neither seems to work.
My code is
and in the text file the data appears in the form
where the first line isn't important.
When I try to read the files I either get the error message or the end of file message without any output
If anyone could help me to get this working I would be very greatful
Thanks
I have some data files that I am trying to read into Fortran but I can't seem to get it to work. I have the data both as text and binary files but neither seems to work.
My code is
Code:
PROGRAM EQLAT
IMPLICIT NONE
REAL :: realvalue ;
CHARACTER(len=21) :: FILENAME ;
INTEGER :: i ;
FILENAME='ggap1979021700pvw.txt' ;
! Open and read the file
OPEN(UNIT=8,FILE=FILENAME,FORM='UNFORMATTED'
& ,STATUS='OLD') ;
i = 1 ;
DO
READ (8,END=999,ERR=1000) realvalue ;
WRITE (*, '(I5, ": ", 1PE13.6)') realvalue ;
i = i + 1 ;
ENDDO
999 WRITE (*, '(/"End-of-file when i = ",I5)') i ;
STOP
1000 WRITE (*, '(/"ERROR reading when i = ", I5)') i ;
STOP
END PROGRAM EQLAT
Code:
35718 1
1.71675e-06
1.29579e-06
9.00909e-07
6.40139e-07
5.06028e-07
4.68775e-07
5.24655e-07
When I try to read the files I either get the error message or the end of file message without any output
If anyone could help me to get this working I would be very greatful
Thanks