Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROGRAM Exercise
- C
- C PARAMETERS
- C
- INTEGER UNUM
- PARAMETER (UNUM=15)
- C
- C LOCAL VARIABLES
- C
- REAL LINES
- C
- C FUNCTION DECLARATIONS
- C
- REAL NUMLIN
- C
- C COMMON VARIABLES
- C
- C
- C DATA STATEMENTS
- C
- C MAIN PROGRAM MODULE
- C
- OPEN(UNIT=UNUM, FILE = 'line.txt', STATUS='OLD')
- LINES=NUNMLIN(UNUM)
- C
- C Rewinding to the top of the file because the pointer is at the end
- C of the file
- C
- REWIND(UNUM)
- CLOSE(UNUM)
- CALL PROCES(UNUM,LINES)
- STOP
- END PROGRAM
- CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C SUBROUTINE PROCES
- C
- C dynamically allocates space
- C
- SUBROUTINE PROCES(U,L)
- CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C FUNCTIONS
- C
- C NUMLIN - counts the number of lines, uses the fact that the file
- C is already open and passes this information to the next subroutine
- C
- REAL FUNCTION NUMLIN(S)
- REAL NUMLIN
- REAL S
- CHARACTER*256 LINE
- 100 READ(S,*,END=200) LINE
- NUMLIN=NUMLIN+1
- GOTO 100
- 200 CONTINUE
- RETURN
- END
- 100 READ(S,*,END=200) LINE
- 1
- 200 CONTINUE
- 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement