     	SUBROUTINE IFINIT( LOUT, IR, ARRAY )
C
C  PROGRAMMER: R.S. ZHOU
C	       ALFRED UNIVERSITY, SEP-1986
C
C	THIS ROUTINE INITIALIZES A PLOT PAGE FOR A HPGL SLIDE-MAKER.
C
C		LOUT --- OUTPUT FILE LOGICAL UNIT
C		IR ----- LENGTH OF "ARRAY"
C		ARRAY -- DEVICE INITIALIZATION PARAMETERS
C
    	INCLUDE 'IMAGEM.CBS'
     	DIMENSION ARRAY(1)
C
C  INITIALIZE COMMON GRAPHIC PARAMETERS...
C
    	IPL = 0
     	DO I=1, NBS+5
     	   IPB(I) = 0
     	ENDDO
     	LUN = LOUT
     	JXO = 0
     	JYO = 0
     	XSCL = 1.0
     	YSCL = 1.0
     	FUNI = 220.0
     	IRR  = IR
    	IF( IRR.GT.0 ) JXO = ARRAY(1)*FUNI
    	IF( IRR.GT.1 ) JYO = ARRAY(2)*FUNI
     	IF( IRR.GT.2 .AND. ARRAY(3).GT.0.0 ) XSCL= ARRAY(3)
     	IF( IRR.GT.3 .AND. ARRAY(4).GT.0.0 ) YSCL= ARRAY(4)
C
C  INITIALIZE THE PLOTTER...
C
     	IPB(IPL+1) = 27		!TURN ON PLOTTER IN CASE OF BYPASS MODE
     	IPB(IPL+2) = '.'
     	IPB(IPL+3) = '('
    	IPB(IPL+4) = 'I'
    	IPB(IPL+5) = 'N'
     	IPB(IPL+6) = 'I'		!LOCATE THE SAVE WINDOW
     	IPB(IPL+7) = 'P'
     	IPL = IPL + 7
     	CALL IFDRAW_CDIF( 200 )
     	IPL = IPL + 1
     	IPB(IPL) = ','
     	CALL IFDRAW_CDIF( 25 )
     	IPL = IPL + 1
     	IPB(IPL) = ','
     	CALL IFDRAW_CDIF( 2400 )
     	IPL = IPL + 1
     	IPB(IPL) = ','
     	CALL IFDRAW_CDIF( 1725 )
     	IPB(IPL+1) = 'S'		!MAP THE SCALE WINDOW
     	IPB(IPL+2) = 'C'
     	IPB(IPL+3) = '0'
     	IPB(IPL+4) = ','
     	IPL = IPL + 4
     	CALL IFDRAW_CDIF( 2200 )
     	IPB(IPL+1) = ','
     	IPB(IPL+2) = '0'
     	IPB(IPL+3) = ','
     	IPL = IPL + 3
     	CALL IFDRAW_CDIF( 1700 )
     	LTY = 1
     	IF( IRR.GT.7 ) THEN
     	    LTY = ARRAY(8)+0.1
     	    IF( LTY.NE.2 ) LTY = 1
     	ENDIF
     	IPB(IPL+1) = 'S'		!FILM TYPE
     	IPB(IPL+2) = 'F'
     	IPB(IPL+3) = 48 + LTY
     	LTY = 1
     	IF( IRR.GT.8 ) THEN
     	    LTY = ARRAY(9)+0.1
     	    IF( LTY.LT.1 ) LTY = 1
     	    IF( LTY.GT.6 ) LTY = 6
     	ENDIF
     	IPB(IPL+4) = 'P'		!PALETTE TYPE
     	IPB(IPL+5) = 'Q'
     	IPB(IPL+6) = 48 + LTY
     	IPB(IPL+7) = 'S'		!CHARACTER SPACING RULE
     	IPB(IPL+8) = 'W'
     	IPB(IPL+9) = '3'
     	IPL = IPL + 9
     	LTY = 1
     	LWD = 0
     	LWID= 1
     	IF( IRR.GT.4 .AND. ARRAY(5).GT.0.0 ) LWID = ARRAY(5)+0.1
     	CALL IFSTYL( LTY, LWID )	!SET PLOTTING STYLUS
999	RETURN
    	END

    	SUBROUTINE IFINIT_DUMP
C
C  PROGRAMMER: R.S. ZHOU,	SEP-1986
C
C	THIS ROUTINE DUMPS THE GRAPHIC BUFFER "IPB".
C
    	INCLUDE 'IMAGEM.CBS'

     	IF( IPL.EQ.0 ) GOTO 999
C
C  DUMP THE BUFFER...
C
     	WRITE(LUN,1) (IPB(I),I=1,IPL)
1	FORMAT(<IPL>A1$)
C
C  NULL THE BUFFER...
C
    	DO I=1, IPL
    	   IPB(I) = 0
    	ENDDO
     	IPL = 0

999	RETURN
    	END

     	SUBROUTINE IFINIT_PLOT( XORG, YORG )
C
C	THIS ROUTINE INITIALIZES A PLOT SESSION.
C
     	INCLUDE 'IMAGEM.CBS'

     	IXO = JXO + INT(XORG*FUNI)
     	IYO = JYO + INT(YORG*FUNI)
     	IXL = IXO
     	IYL = IYO
     	ILP = 0
     	IFN = 1
     	IFP = 0
     	JSK = 0
     	XANG = 0.0
     	YANG = 0.0
     	XCTH = 1.0
     	XSTH = 0.0
     	YCTH = 1.0
     	YSTH = 0.0
     	XORS = 0.0
     	YORS = 0.0
     	CALL IFDRAW(0.0,0.0,3)		!MOVE TO THE ORIGIN
     	RETURN
     	END

