    	SUBROUTINE LAYOUT_ROTATE( RANG, XP, YP )
C
C  PROGRAMMER: R.S. ZHOU		JUNE-1986
C
C	THIS ROUTINE ROTATES PICKED LAYOUT SEGMENTS
C	BY "RANG" DEGREES WITH THE PIVOT AT (XP, YP).
C	IF XP OR YP .EQ. 99.0, THE SEGMENTS ARE ROTATED
C	AROUND THEIR OWN INDIVIDUAL PIVOTS.
C
    	INCLUDE		'LAYOUT.CBS'
     	LOGICAL		SKIP, ONE
     	DIMENSION	IR(9)
     	DATA		IR/ 6, 6, 6, 6, 5, 6, 4, 5, 6 /

     	IF( RANG.EQ.0.0 ) RETURN

    	XOP = XP
    	YOP = YP
    	ANG = AMOD( RANG, 360.0 )
    	CTH = COS( ANG*D2R )
    	STH = SIN( ANG*D2R )
    	ONE = .FALSE.
    	IF( XOP.EQ.99.0 .OR. YOP.EQ.99.0 ) ONE = .TRUE.

    	DO  222 I = 1, NLG
     	    SKIP = .FALSE.
    	    IS = NLS(I)
     	    DO  111 J = 1, NLC
     		IF( NSN(J).NE.IS ) GOTO 111
     		IF( ONE ) THEN
     		    XPS = P00(1,J)
     		    YPS = P00(2,J)
     		ELSE
     		    XP1 = P00(1,J)
     		    YP1 = P00(2,J)
     		    XPS = XOP+(XP1-XOP)*CTH-(YP1-YOP)*STH
     		    YPS = YOP+(YP1-YOP)*CTH+(XP1-XOP)*STH
     		    P00(1,J) = XPS
     		    P00(2,J) = YPS
     		ENDIF
     		RAN(J) = AMOD( RAN(J)+ANG, 360.0 )
     		IF(.NOT.SKIP) CALL IFSEG_TRAN( IS, XPS, YPS,
     1                             RAN(J), ZXF(J), ZYF(J) )
     		ITT = IR(NID(J))
     		P00(ITT,J) = AMOD( P00(ITT,J)+ANG, 360.0 )
     		IF( NFL(J).EQ.0 ) GOTO 222
     		SKIP = .TRUE.
111	    CONTINUE
222	CONTINUE

     	CALL IFINIT_DUMP

    	RETURN
    	END

    	SUBROUTINE LAYOUT_ROTATE_ANGLE( IP, ANG )
C
C  THIS ROUTINE ASSIGNS DIFFERENT INCREMENTAL ROTATION ANGLES "ANG"
C  ACCORDING TO "IP" FOR LAYOUT PLOTTING
C
    	SAVE IOPL

    	IOP = IP
    	ANG = 0.0
    	IF( IOP.EQ.1 ) THEN
     	    ANG = 1.0
     	ELSE IF( IOP.EQ.2 ) THEN
     	    ANG = 10.0
     	ELSE IF( IOP.EQ.3 ) THEN
     	    ANG = -1.0
     	ELSE IF( IOP.EQ.4 ) THEN
     	    ANG = 2.0
     	ELSE IF( IOP.EQ.5 ) THEN
    	    IF(IOPL.NE.10) THEN
    	        IOPL = 10
    	    ELSE
    	        IOPL = 1
    	    ENDIF
    	ELSE IF( IOP.EQ.6 ) THEN
     	    ANG = -2.0
     	ELSE IF( IOP.EQ.7 ) THEN
     	    ANG = 5.0
     	ELSE IF( IOP.EQ.8 ) THEN
     	    ANG = -10.0
     	ELSE IF( IOP.EQ.9 ) THEN
     	    ANG = -5.0
     	ELSE IF( IOP.EQ.0 ) THEN
    	    IF(IOPL.NE.25) THEN
    	        IOPL = 25
    	    ELSE
    	        IOPL = 10
    	    ENDIF
    	ENDIF
    	IF( IOPL.EQ.0 ) IOPL = 1
    	ANG = ANG * IOPL

    	RETURN
    	END
