
C
C	SUBROUTINE CRTFIL
C
C
C	CALL IS
C
C
C		CALL CRTFIL(FLNAME,NUMBKS,ITCHAN,IOPN)
C
C
C	WHERE
C
C	FLNAME	IS NAME OF FILE POSITIONED SO USR DOES NOT SWAP
C		OVER IT
C	NUMBKS	IS NUMBER OF BLOCKS IN FILE
C	ITCHAN	IS CHANNEL ASSOCIATED WITH FILE
C	IOPN	FLAG FOR FILE CREATION
C		-1 OPEN FILE AND SAVE
C		0  OPEN FILE AND DO NOT SAVE
C		1  OPEN EXISTING FILE AND DO NOT DELETE
C
C
	SUBROUTINE CRTFIL(FLNAME,NUMBKS,ITCHAN,IOPN)
	REAL*8 FLNAME
5	CALL CHKNEG(IGETC(),ITCHAN,0)
	CALL CHKPOS(IFETCH(FLNAME),ICHK,0)
	IF (IOPN.GT.0) GOTO 10
C
C	DELETE FILE BEFORE ENTER
C
	ICHK = 2				!IGNORE FILE NOT FOUND
	CALL CHKPOS(IDELET(ITCHAN,FLNAME),ICHK,0)
	CALL ENTERR(IENTER(ITCHAN,FLNAME,NUMBKS),IENT,0)
	RETURN
C10	NUMBKS = -1			!IGNORE -1 ERROR
10	CALL LOKERR(LOOKUP(ITCHAN,FLNAME),NUMBKS,0)
D	TYPE *,'CRTFIL',NUMBKS
	IF (NUMBKS.EQ.-1) GOTO 5
	RETURN
	END
