C ***  ASCBIN
C *
C *  PROGRAMMER:  SCOTT HOWARD
C *               ALFRED UNIVERSITY
C *
C *  THIS PROGRAM CONVERTS THE ASCII FILES (WRITTEN ON THE PDP SYSTEMS)
C *       BINARY FILES FOR THE VAX ENVIROMENT.
C *
	CHARACTER LINE*80, LINE1(80)*1, DATIM(17)*1
	CHARACTER CONVRT*2, KFILEI*20, KFILEO*20
	DIMENSION DATA(10),IDATA(10)
	EQUIVALENCE (LINE,LINE1)
C *
	WRITE(6,1000)
1000	FORMAT(' ASCBIN - CONVERTS ASCII TO BINARY FILES')
C *
1001	WRITE(6,1002)
1002	FORMAT(/'$CONVERSION? (AB) ASCII->BINARY (BA) ',
	1'BINARY->ASCII <BA> :')
	READ(5,1003) CONVRT
1003	FORMAT(A2)
	IF(CONVRT.NE.'AB'.AND.CONVRT.NE.'BA') GO TO 1001
C *
C *  OPEN THE FILES
	WRITE(6,1010)
1010	FORMAT(/'$ENTER INPUT FILE NAME:')
	READ(5,1012) KFILEI
1012	FORMAT(A20)
	WRITE(6,1030)
1030	FORMAT('$ENTER OUTPUT FILE NAME:')
	READ(5,1012) KFILEO
	IF(CONVRT.EQ.'AB') THEN
	  OPEN(UNIT=10,FILE=KFILEI,STATUS='OLD',FORM='FORMATTED',
	1 READONLY)
	  OPEN(UNIT=20,FILE=KFILEO,STATUS='NEW',FORM='UNFORMATTED')
	ENDIF
	IF(CONVRT.EQ.'BA') THEN
	  OPEN(UNIT=10,FILE=KFILEI,STATUS='OLD',FORM='UNFORMATTED',
	1 READONLY)
	  OPEN(UNIT=20,FILE=KFILEO,STATUS='NEW',FORM='FORMATTED',
	1 CARRIAGECONTROL='LIST')
	ENDIF
C *
	IF(CONVRT.EQ.'BA') GO TO 3000
C *
C **  CONVERSION FOR ASCII TO BINARY
C *
C *  READ TITLE
2000	READ(10,2001) LINE1
2001	FORMAT(80A1)
	WRITE(6,2005) LINE1
2005	FORMAT(' ',80A1)
	WRITE(20) LINE1
C *
C *  READ DATE/TIME
	READ(10,2001) DATIM
	WRITE(6,2005) DATIM
	WRITE(20) DATIM
C *
C *  READ THE RUN TIME PARAMETERS
	READ(10,2002) (DATA(I),I=1,4)
2002	FORMAT(4F10.4)
	WRITE(20) (DATA(I),I=1,4)
	FTIME = DATA(4)
C *
C *  REFORMAT INTENSITY DATA
2010	READ(10,2003,END=4000) LINE1
2003	FORMAT(80A1)
	READ(LINE,2006) IDATA
2006	FORMAT(10(X,I7))
	DO 2015 I=1,10
2015	DATA(I) = FLOAT( IDATA(I) ) / FTIME
	WRITE(20) DATA
	GO TO 2010
C *
C **  CONVERSION IS FROM BINARY TO ASCII
C *
C *  READ TITLE
3000	READ(10) LINE1
	WRITE(6,3005) LINE1
3005	FORMAT(' ',80A1)
	WRITE(20,3001) LINE1
3001	FORMAT(80A1)
C *
C *  READ DATE/TIME
	READ(10) DATIM
	WRITE(6,3005) DATIM
	WRITE(20,3001) DATIM
C *
C *  READ THE RUN TIME PARAMETERS
	READ(10) (DATA(I),I=1,4)
	WRITE(20,3002) (DATA(I),I=1,4)
3002	FORMAT(4F10.4)
	FTIME = DATA(4)
C *
C *  REFORMAT INTENSITY DATA
3010	READ(10,END=4000) DATA
	DO 3015 I=1,10
3015	IDATA(I) = NINT( DATA(I) * FTIME )
	WRITE(20,3020) IDATA
3020	FORMAT(10(X,I7))
	GO TO 3010
C *
4000	CLOSE(UNIT=10)
	CLOSE(UNIT=20)
	STOP'FILE CONVERTED'
	END
