
C** RENUM1 ** SUBROUTINE FOR RENUM TO FIND THE STATE.NUM LABELS
C
	SUBROUTINE RENUM1
C
	LOGICAL*1 LINE(134)
	LOGICAL*1 IC,ID,DEBUG,TAB,NBLK,LOST
	COMMON LINEN,MAXLIN,IPAGE,INC,IERROR,IBEGIN,ICOUNT,DEBUG,LOST,
	$ OLD(499),LINE
	DATA IC/'C'/,ID/'D'/,NBLK/' '/,TAB/"11/
C
C
	ICOUNT=0
	IEND=5		!CHECK ONLY THE STATEMENT NUM FIELD
	DO 2 I=1,499		!CLEAR OLD
2	OLD(I)=0.
C
C============READ A LINE
C
4	READ (1,6,END=12) IQ,LINE
6	FORMAT (Q,134A1)
	IF (IQ .LE. 4) GO TO 4				!SKIP NON-LINES
	IF (LINE(1) .EQ. IC) GO TO 4			!SKIP COMMENTS
	IF (LINE(1) .EQ. ID .AND. .NOT. DEBUG) GO TO 4	!DEBUG LINES
	IF (LINE(1) .EQ. TAB) GO TO 4		!CANNOT CONTAIN A NUM
C
	ISTART=1
	XOLD=OLDNUM(LINE,IEND,ISTART,ISTOP)
	IF (XOLD .EQ. 0.) GO TO 4			!NONE FOUND
	ICOUNT=ICOUNT+1				!FOUND ONE, FILE IT
	OLD(ICOUNT)=XOLD
C
C--CHECK TO BE SURE THERE ARE NO DUPLICATE STATEMENT NUMBERS
C
	IF (ICOUNT .EQ. 1) GO TO 10
	DO 8 I=1,ICOUNT-1
	IF (OLD(I) .EQ. OLD(ICOUNT)) STOP '*ABORTING--DUPLICATE STATEMENT
	1 NUMBERS*'
8	CONTINUE
C
10	IF (ICOUNT .LT. 499) GO TO 4
	STOP '*ABORTING-TOO MANY STATEMENT NUMBERS IN PROGRAM*'
C
12	CONTINUE
D	WRITE (6,99) ICOUNT,(OLD(N),N=1,ICOUNT)
D99	FORMAT (' ICOUNT=',I7/10(10F7.0/))
	RETURN
	END
C** HELPR SUBROUTINE FOR RENUM TO PROVIDE HELP ON TT: ******
C
C
	SUBROUTINE HELPR
C
	WRITE (5,14)
14	FORMAT ('0RENUM V4 SWITCHES:'/'0/X  PRODUCE CROSS REFERENCE INDEX
	1 OF VARIABLE NAMES'/' /R  RE-STATEMENT NUMBER SOURCE CODE
	3 INTO OUTPUT FILE'/' /S  PRINT JUST THE CROSS
	4 REFERENCE VARIABLE INDEX (ELSE SOURCE CODE)'/' /D  TREAT DEBUG 
	4LINES AS VALID CODE, ELSE AS COMMENTS'/
	9' /I!N  SET NEW STATEMENT NUMBER INCREMENT TO N'/
	9' /B!N  SET BEGINNING NEW STATEMENT NUMBER TO N'/
	9' /H  WRITE THIS HELP ON
	5 THE TRMINAL'/'0COMMAND LINE:  *[OUT][,LIST]=IN1[,IN
	62...IN6][/SWITCHS]'/
	4' "C** " IN COL 1-4 OF 1ST LINE OF CODE MAKES IT A HEADER.'/
	1' TO CREATE AN OUTPUT FILE OF RENUMBERED CODE, YOU MUST 
	2SPECIFY'/' AN OUTPUT FILE. HOWEVER, IT''S NAME IS A DUMMY-THE
	3 OUTPUT FILES(S)'/' ALWAYS HAVE THE SAME NAME(S) AS THE ORIGINAL
	4 SOURCE CODE FILE(S).'/' MULTIPLE SOURCE MODULES IN
	5 A SINGLE INPUT FILE MUST NOT HAVE DUPLICATE'/'
	5 STATEMENT NUMBERS BECAUSE ALL PROGRAM MODULES WILL BE
	5 RENUMBERED AND'/' CROSS REFERENCED AS A UNIT.'/
	6' DEFAULTS:'/' DEVICE = DK:; LIST FILE EXTENSION = .LST; INPUT FILE
	7'/' EXTENSION = .FOR; SWITCHES = /X+/R+/I!2+/B!2 (NOT /S OR /D)'/
	8' PROGRAMS BEING RENUMBERED MUST NOT HAVE STATEMENT NUMBERS
	9 EXTENDING'/' OVER THE END OF A LINE ONTO A CONTINUATION
	1 LINE.'/' THE USE OF FORTRAN KEYWORDS AS VARIABLE NAMES AND EXCES
	$SIVE BLANKS ARE'/' BEST AVOIDED.  DUPLICATE STATEMENT NUMBERS WILL
	$ CAUSE RENUM TO ABORT.'/' THE /D SWITCH MUST BE USED WITH CAUTION
	$ TO AVOID DUPLICATE STATEMENT'/' NUMBERS ON LATER RENUMS'/)
	RETURN
	END

