        SUBROUTINE DEVSEL(NEWDEV,LUN,IERR)
C
C
        INCLUDE GCDSEL.PRM
        INCLUDE GCDPRM.PRM
        INCLUDE GCCPAR.PRM
        INCLUDE GCVPOS.PRM
        INCLUDE GCAPOS.PRM
        INCLUDE GCCLIP.PRM
        INCLUDE GCDCHR.PRM
        INCLUDE GCLTYP.PRM
        DIMENSION DEVCHR(8), GDCOMN(5)
        DIMENSION DFDIST(4,3)
C
C       DEFINE DEFAULT LINE STYLES
C
        EQUIVALENCE (DEVID,GDCOMN(1))
        DATA DFDIST /
     1    0.5,  0.5,  0.5,  0.5,
     2   0.25, 0.25, 0.25, 0.25,
     3    0.5, 0.25, 0.25, 0.25/
C
C       RELEASE CURRENT DEVICE
C
        IF (IDEV .NE. 0) CALL GSDRVR(6,DUMMY,DUMMY)
C
C       NOW INIT. THE NEW DEVICE
C
        IF (NEWDEV .LE. 0) GO TO 900
        IDEV = NEWDEV

C
C       INITIALIZE THE DEVICE FOR DIGLIB GRAPHICS
C
        CALL GSDRVR(1,FLOAT(LUN),DUMMY)
        IERR = DUMMY
        IF (IERR .NE. 0) GO TO 910
C
C       GET THE DEVICE CHARACTERISTICS 
C
        DEVCHR(8) = 1.0
        CALL GSDRVR(7,DEVCHR,DUMMY)
        IF (DEVCHR(1) .EQ. 0.0) GO TO 900
C
C       SET DEVICE CHARACTERISTICS FOR LATER USE
C
        DO 100 I=1,5
100     GDCOMN(I) = DEVCHR(I)
	XLENCM = DEVCHR(2)
	YLENCM = DEVCHR(3)
	XRES   = DEVCHR(4)
	YRES   = DEVCHR(5)
        NDCLRS = DEVCHR(6)
        IDVBTS = DEVCHR(7)
        NFLINE = DEVCHR(8)
        XCLIPD = XLENCM + 0.499/DEVCHR(4)
        YCLIPD = YLENCM + 0.499/DEVCHR(5)
C
C       NOW INIT THE PARAMETERS
C
        XS = 1.0
        YS = 1.0
        XT = 0.0
        YT = 0.0
        RCOS = 1.0
        RSIN = 0.0
        CSIZE = GOODCS(0.3)
        CCOS = 1.0
        CSIN = 0.0
        XCUR = 0.0
        YCUR = 0.0
        IVIS = 0
        XCM0 = 0.0
        YCM0 = 0.0
        XCM1 = XCLIPD
        YCM1 = YCLIPD
        ILNTYP = 1
                DO 120 I=1,3
                        DO 110 J=1,4
                        DIST(J,I) = DFDIST(J,I)
110                     CONTINUE
120             CONTINUE
        LCURNT = .FALSE.
        RETURN
C
C       NON-EXISTANT DEVICE SELECTED, REPORT ERROR AND DESELECT DEVICE
C
900     IERR = -1
C
C       DEVICE INITIALIZATION FAILED, DESELCT DEVICE
C
910     IDEV = 0
        RETURN
        END

