     	PARAMETER D2R= 0.17453292E-1	!DEGREE TO RADIAN CONVERSION FACTOR.
     	REAL*4 LENGTH
     	DIMENSION XP(10), YP(10)
     	CHARACTER KEYW*4, RECORD*130, OLDFILE*32, NEWFILE*32
     	EQUIVALENCE (KEYW,RECORD(1:4))

     	WRITE(6,1000)
1000	FORMAT(//' DES_CONVERT: GRAFIT layout file update routine.'/)

   1	WRITE(6,1001)
1001	FORMAT('$Old layout file [.DES] ')
     	READ(5,1002,END=999) OLDFILE
1002	FORMAT(A)
     	IF( OLDFILE.EQ.' ' ) GOTO 999

     	WRITE(6,1003)
1003	FORMAT('$New layout file [.DES] ')
     	READ(5,1002,END=999) NEWFILE
     	IF( NEWFILE.EQ.' ' ) NEWFILE = OLDFILE

     	CALL IFMISC_DEFEXT( OLDFILE, '.DES' )
     	CALL IFMISC_DEFEXT( NEWFILE, '.DES' )

     	OPEN( UNIT=1, FILE=OLDFILE, STATUS='OLD', FORM='FORMATTED',
     1  CARRIAGECONTROL='LIST', ERR=111 )

     	OPEN( UNIT=2, FILE=NEWFILE, STATUS='NEW', FORM='FORMATTED',
     1  CARRIAGECONTROL='LIST' )

     	Z = 0.0
     	X = 1.0
     	W = 1.0
     	GOTO 222
111	WRITE(6,112)
112	FORMAT('__ERROR: can not open/find the old file.')
     	CLOSE(UNIT=1)
     	GOTO 1

222	READ(1,1002,ERR=222,END=999) RECORD

     	READ(RECORD,2002,ERR=222) P1,P2,P3,P4,P5,P6,P7,P8,P9,
     1                            P10,P11,P12,P13
2002	    FORMAT(5X,F3.0,12(',',F7.2))

     	IF( KEYW.EQ.'BARS' ) THEN
     	    WRITE(2,2004) P1,P2+.5*P4,P3+.5*P5,P4,P5,Z,P6,P7,X,W
2004	    FORMAT('BARS:',10F8.3)
     	    GOTO 222
     	ENDIF

     	IF( KEYW.EQ.'BOXS' ) THEN
     	    WRITE(2,2004) P1,P2+.5*P4,P3+.5*P5,P4,P5,ABS(P6),P7,P8,X,W
     	    GOTO 222
     	ENDIF

     	IF( KEYW.EQ.'ARCS' ) THEN
     	    WRITE(2,2005) P1,P2,P3,P4,P4,ABS(P5),Z,P6,P7,P8,X,W
2005	    FORMAT('ARCS:',12F8.3)
     	    GOTO 222
     	ENDIF

     	IF( KEYW.EQ.'ELLP' ) THEN
     	    WRITE(2,2005) P1,P2,P3,P4,P5,ABS(P6),P7,P8,P9,P10,X,W
     	    GOTO 222
     	ENDIF

     	IF( KEYW.EQ.'OBLI' ) THEN
     	    WRITE(2,2006) P1,P2,P3,2.0*P4,2.0*P5,ABS(P6),P7,P8,X,W
2006	    FORMAT('OBLI:',10F8.3)
     	    GOTO 222
     	ENDIF

     	IF( KEYW.EQ.'POLY' ) THEN
     	    WRITE(2,2007) P1,P2,P3,2.0*P4,ABS(P5),P6,P7,P8,X,W
2007	    FORMAT('POLY:',10F8.3)
     	    GOTO 222
     	ENDIF

     	IF( KEYW.EQ.'SYMB' ) THEN
     	    WRITE(2,2008) P1,P2,P3,P4,P6,P7
2008	    FORMAT('MARK:',6F8.3)
     	    GOTO 222
     	ENDIF

     	IF( KEYW.EQ.'ARRH' ) THEN
     	    P10 = 3.0
     	    IF( P9.NE.0.0 ) P10 = 4.0
     	    P8 = AMOD( P8+180.0, 360.0 )
     	    WRITE(2,2009) P1,P2,P3,P4,P5,P7*P4,P8,P10
2009	    FORMAT('ARRH:',8F8.3)
     	    GOTO 222
     	ENDIF

     	IF( KEYW.EQ.'TEXT' ) THEN
     	    READ(1,1002,ERR=222,END=999) RECORD
     	    NCH = P7
     	    IF( NCH.GT.75 ) NCH = 75
     	    IPN = P1
     	    WRITE(2,2001) IPN,P2,P3,P4,P5,P6,RECORD(6:5+NCH)
2001	    FORMAT('TEXT:',I2,5F8.3,',',A<NCH>)
     	ENDIF

     	IF( KEYW.EQ.'LINE' ) THEN
     	    READ(1,2010,ERR=222,END=999) XP
     	    READ(1,2010,ERR=222,END=999) YP
2010	    FORMAT(5X,10F8.2)
     	    NCH = ABS(P4)
     	    IF( P6.LT.0.0 .AND. NCH.EQ.2 ) THEN		!ARROWHEAD
     		P5 = 1.0
     		IF( P6.LT.-10.0 ) P5 = 11.0
     		CTH= COS(D2R*P11)
     		STH= SIN(D2R*P11)
     		P8 = P12*(XP(2)*CTH-YP(2)*STH)
     		P9 = P13*(XP(2)*STH+YP(2)*CTH)
     		P2 = P2 + P8
     		P3 = P3 + P9
     		P10= SQRT( P8**2 + P9**2 )
     		P9 = ASIN( P9/P10 )/D2R
     		IF( P8.LT.0.0 ) P9 = 180.0-P9
     		P11 = 0.03
     		P12 = 0.10
     		WRITE(2,2009) P1,P2,P3,P10,P11,P12,P9,P5
     	    ELSE IF( NCH.EQ.2 ) THEN			!LINE
     		P6 = AMOD( P6, 10.0 )
     		WRITE(2,2011) P1,P2,P3,P4,P12,P13,P11,Z,P6,W,XP(2),YP(2)
     	    ELSE
     		IF( P6.LT.0.0 ) P4 = -P4
     		P6 = AMOD( ABS(P6), 10.0 )
     		WRITE(2,2011) P1,P2,P3,P4,P12,P13,P11,P7,P6,W
2011		FORMAT('LINE:',12F8.3)
     		WRITE(2,2012) XP, YP
2012		FORMAT('COOX:',10F8.3,/'COOY:',10F8.3)
     	    ENDIF
     	    GOTO 222
     	ENDIF
     	GOTO 222

999	CLOSE(UNIT=1)
     	CLOSE(UNIT=2)
     	CALL EXIT
     	END
