	PROGRAM INCSMN
C
C	FUNCTION:
C		TO LOCATE SM ON LINE N AND TO INCREMENT MATRIX BY ONE
C
C
	INTEGER ICNT(256),STRLIN(10)
	LOGICAL*1 BCNT(512),ERR,BYT1,BYT2,BYT3
	LOGICAL*1 TITLE(6)
	EQUIVALENCE (ICNT,BCNT,FILE)
	REAL*8 GAMMAL
	DATA GAMMAL/12RSY0GAMMALSYS/
	DATA TITLE/'I','N','C','S','M','N'/
	DATA STRLIN/2,53,104,155,206,257,308,359,410,461/
	CALL GAMSTP(ICNT,TITLE)
	NLINE = -1
C
C	OPEN SAVE AREA ZERO TO CURRENT LINE
C
	CALL SAVOP(0,ISAVE0,ICNT,IERR)
	ITP = 33
	CALL READW(256,ICNT,ITP,ISAVE0)
	LINE  = ICNT(39)
C
C	GET PARAMETERS
C
	CALL GPV(1,NPF,ICNT,ERR)
	IF (ERR.LT.0) STOP 'PARAMETER MISSING IN INCSMN'
	IF (NPF.LE.0) STOP 'PARAMETERS MISSIMG IN INCSMN OR GT 1'
	MAXSVA = ICNT(1)		!LAST SAVE AREA

C
C	OPEN GAMMAL.SYS TO INCREMENT SM N
C
1	CALL CRTFIL(GAMMAL,53,IGAMML,1)
	ITP = 0
	CALL READW(256,BCNT,ITP,IGAMML)
	DO 5 I = STRLIN(LINE),STRLIN(LINE)+49
C
C	END OF CURRENT LINE ??
C
	IF (BCNT(I).EQ."200) GOTO 7
C
C	SEARCH FOR SM
C
	IF (BCNT(I).EQ.'S'.AND.BCNT(I+1).EQ.'M') GOTO 4
	GOTO 5
C
C	SEARCH FOR LINE SM20;RU INCSMN!!39  IE ;
C
4	IF (BCNT(I+4).EQ."73) GOTO 30
5	CONTINUE
7	WRITE(7,29)
29	FORMAT(' ERROR IN MACRO - FORMAT MUST BE',//
	1,'??????;SM02;RU INCSMN!!39',/)
	STOP 'INCSMN'
	GOTO 20
C
C	SET UP TO INCREMENT 2 DIGIT SVAR'S
C
30	BCNT(I+3) = BCNT(I+3) + 1
	IF (BCNT(I+3).NE."72) GOTO 11
	BCNT(I+2) = BCNT(I+2) + 1
	BCNT(I+3) = "60
11	DECODE(2,27,BCNT(I+2))NXTSVA
27	FORMAT(I2)
	IF (NXTSVA.GT.MAXSVA) GOTO 20
	ITP = 0
	CALL WRITW(256,BCNT,ITP,IGAMML)
C
C	CLOSE ALL CHANNELS
C
20	DO 15 J = 1,10
	I = J - 1
	CALL CLOSEC(I)
15	CALL IFREEC(I)
	IF (NXTSVA.GT.MAXSVA) GOTO 25
	CALL GAMCA(ICNT,NLINE)
25	WRITE(7,31)
31	FORMAT(//,' LAST STUDY STORED RETURN TO BGAMMA'//)
	CALL BGAMMA('')
	END
