I am trying to count the number of lines in a file in Fortran 77 (My file has two columns, both with numbers)
I am getting an unclassifiable statement and unexpected data declaration and I am not sure why. This is my code: (new to fortran 77):
PROGRAM Exercise
C
C John Smith
C
C
C PARAMETERS
C
REAL PRECISION UNUM
PARAMETER (UNUM=15)
C
C LOCAL VARIABLES
C
C
C FUNCTION DECLARATIONS
C
INTEGER*8 PRECISION NUMLIN
C
C COMMON VARIABLES
C
C
C DATA STATEMENTS
C
DATA FILEN /'linecounttester.txt'/
C
C MAIN PROGRAM MODULE
C
OPEN(UNIT=UNUM, FILE = FILEN, STATUS='OLD')
C
C function counts the lines in the file
C
FUNCTION NUMLIN
INTEGER*8 PRECISION NUMLIN
CHARACTER*256 LINE
100 READ(UNUM,*,END=200) LINE
NUMLIN=NUMLIN+1
GOTO 100
200 CONTINUE
RETURN
END
REWIND(UNUM)
CLOSE(UNUM)
This is my data file: (just a tester so I can count the lines to 8): 1 100 2 200 3 300 4 400 5 500 6 600 7 700 8 800
These are my errors:
Exercise.for:58.6:
FUNCTION NUMLIN
1
Error: Unclassifiable statement at (1) Exercise.for:59.32:
INTEGER*8 PRECISION NUMLIN
1
Error: Symbol 'precisionnumlin' at (1) already has basic type of INTEGER Exercise.for:60.72:
CHARACTER*256 LINE
1
Error: Unexpected data declaration statement at (1) Exercise.for:61.7:
100 READ(UNUM,*,END=200)
1
Error: Invalid character in name at (1) Exercise.for:62.6:
LINE
1
Error: Unclassifiable statement at (1) Exercise.for:65.7:
200 CONTINUE
1
Error: Invalid character in name at (1) Exercise.for:41.10:
DATA FILEN /'linecounttester.txt'/
1
Error: Incompatible types in DATA statement at (1); attempted conversion of CHARACTER(1) to REAL(4) Exercise.for:46.16:
OPEN(UNIT=UNUM, FILE = FILEN, STATUS='OLD')
1
Error: UNIT tag at (1) must be of type INTEGER Exercise.for:64.72:
GOTO 100
1
Error: Label 100 referenced at (1) is never defined Exercise.for:1.72:
PROGRAM EXERCISE
1
Exercise.for:70.72:
REWIND(UNUM)
2
Error: Two main PROGRAMs at (1) and (2)
Can anyone help me out?