      SUBROUTINE PLOTPH(XL,TIMES,PHASES,SIGPH,E,OMINC,NPHASE,TITLE,IEB)
C     
C     ROUTINE TO PLOT:  
C     ARRAY PHASES IF IEB>=0, OMINC IF IEB<0 UP THE Y AXIS  
C     ARRAY TIMES  IF IEB>-2, E     IF IEB=-2 ALONG THE X AXIS    
C     IF IEB=0 OR -2, NO ERROR BARS ARE PRODUCED
C     
      COMMON /PLOTFL/PLNAME
      CHARACTER PLNAME*12
      DIMENSION TIMES(1),PHASES(1),SIGPH(1),E(1),OMINC(1)   
      CHARACTER TITLE*80,YTITLE*20,XTITLE*20 
      YL=6.0
      IF(IEB.LT.0)YL=4.0
C
C     INITIALISE THE PLOTTING
C
c      CALL SETCC
c     CALL PLFILE(PLNAME)
c     CALL PLOTS(IERR,IDUMMY,28)
      IF(IERR.NE.0) STOP 'ERROR ON OPENING SPOOLTEK CALL'
c     CALL FACTOR(2.54) 
c     CALL FRAME(XL+4.0,YL+4.0)          
c     CALL PLOT(1.5,1.5,-3)   
c     CALL SYMBOL(0.,YL+1.5,0.2,TITLE,0.,60)  
      PI=3.141592653    
      IF(IEB.GT.-2)THEN 
        XTITLE='TIME (S)'     
c       CALL SCALE(TIMES,XL,NPHASE,1)     
        TT=TIMES(NPHASE+1)    
        TTT=TIMES(NPHASE+2)   
      ELSE  
c       CALL SCALE(E,XL,NPHASE,1)   
        TT=E(NPHASE+1)  
        TTT=E(NPHASE+2) 
        XTITLE=' CYCLE  '     
      END IF
      IF(IEB.GE.0)THEN  
        PHMAX=3.*PI     
        PHMIN=-PI 
        PHSCAL=(PHMAX-PHMIN)/YL     
        YY=-180.0 
        YYY=720.0/YL    
        YTITLE='PHASE (DEGREES)'    
      ELSE  
        OMCMAX=-0.5     
        OMCMIN=0.5
        OMCSCL=-1.0/YL  
        YY=OMCMIN 
        YYY=OMCSCL
        YTITLE=' O-C  (CYCLES) '    
      END IF
c     CALL AXIS(0.0,0.0,XTITLE,-8,XL,0.,TT,TTT) 
c     CALL AXIS(0.0,YL,XTITLE,8,XL,0.,TT,TTT)   
c     CALL AXIS(0.,0.,YTITLE,16,YL,90.0,YY,YYY) 
c     CALL AXIS(XL,0.,YTITLE,-16,YL,90.0,YY,YYY)
      DO 10 J=1,NPHASE  
        IF(IEB.GT.-2)THEN     
          X=(TIMES(J)-TT)/TTT 
        ELSE
          X=(E(J)-TT)/TTT     
        END IF    
        IF(IEB.GE.0)THEN
          Y=(PHASES(J)-PHMIN)/PHSCAL
          ERROR=SIGPH(J)/PHSCAL     
        ELSE
          Y=(OMINC(J)-OMCMIN)/OMCSCL
          IF(Y.LT.0.0)Y=Y+1.0/ABS(OMCSCL) 
          IF(Y.GT.YL)Y=Y-1.0/ABS(OMCSCL)  
          IF(IEB.GT.-2)ERROR=SIGPH(J)/(2.0*PI)/ABS(OMCSCL)   
        END IF    
c       CALL SYMBOL(X,Y,0.05,1,0.0,-1)    
        IF (IEB.EQ.0.OR.IEB.EQ.-2.OR.ERROR.EQ.0.0) GOTO 10
        TOP=Y+ERROR     
        BOTTOM=Y-ERROR  
        IF(TOP.GT.YL)TOP=YL   
        IF(BOTTOM.LT.0.0)BOTTOM=0.0 
c       CALL PLOT(X+0.05,TOP,3)     
c       CALL PLOT(X-0.05,TOP,2)     
c       CALL PLOT(X,TOP,3)    
c       CALL PLOT(X,BOTTOM,2) 
c       CALL PLOT(X+0.05,BOTTOM,3)  
c       CALL PLOT(X-0.05,BOTTOM,2)  
   10 CONTINUE    
      IF(IEB.LT.0)GO TO 25    
      DO 20 J=1,NPHASE  
        X=(TIMES(J)-TT)/TTT   
        Y=(PHASES(J)+2.0*PI-PHMIN)/PHSCAL 
c       CALL SYMBOL(X,Y,0.05,1,0.0,-1)    
        IF (IEB.EQ.0) GOTO 20 
        ERROR=SIGPH(J)/PHSCAL 
        TOP=Y+ERROR     
        BOTTOM=Y-ERROR  
        IF(TOP.GT.YL)TOP=YL   
        IF(BOTTOM.LT.0.0)BOTTOM=0.0 
c       CALL PLOT(X+0.05,TOP,3)     
c       CALL PLOT(X-0.05,TOP,2)     
c       CALL PLOT(X,TOP,3)    
c       CALL PLOT(X,BOTTOM,2) 
c       CALL PLOT(X+0.05,BOTTOM,3)  
c       CALL PLOT(X-0.05,BOTTOM,2)  
   20 CONTINUE    
   25 CONTINUE
c     CALL PLOT(0.0,0.0,999) 
      RETURN
      END   
