* Last processed by NICE on 12-Jun-2000 15:53:00
* Customized for :  IEEE, LINUX, UNIX, MOTIF, F77
      SUBROUTINE FLAG (LINE,COMM,ERROR)
      CHARACTER*(*) LINE,COMM
      LOGICAL ERROR
*
      WRITE(6,*) 'W-FLAG,  Not yet implemented'
      END
*<FF>
      SUBROUTINE PLOT_RESULT (LINE,COMM,ERROR)
      CHARACTER*(*) LINE,COMM
      LOGICAL ERROR
*
      INCLUDE 'setup.inc'
*
      INTEGER MVOC1,MVOC2
      PARAMETER (MVOC1=6,MVOC2=2)
      INTEGER NKEY1,NKEY2,NA
      CHARACTER*12 VOCAB1(MVOC1),VOCAB2(MVOC2),ARGUM,KEYW1,KEYW2
      LOGICAL SIC_PRESENT
*
      DATA VOCAB1 /'ERRORS','RESIDUALS','SUMMARY','TIME','CIRCLE',
     $'COVERAGE'/
      DATA VOCAB2 /'AZIMUTH','ELEVATION'/
*
      IF (.NOT.FITTED) WRITE(6,*) 'W-PLOT,  No fit was done'
      IF (SIC_PRESENT(0,1)) THEN
         CALL SIC_CH (LINE,0,1,ARGUM,NA,.TRUE.,ERROR)
         IF (ERROR) RETURN
         CALL SIC_AMBIGS('PLOT',ARGUM,KEYW1,NKEY1,VOCAB1,MVOC1,
     $   ERROR)
         IF (ERROR) RETURN
      ELSE
         NKEY1 = 3
         KEYW1 = 'SUMMARY'
      ENDIF
*
      DOBAD = SIC_PRESENT(1,0)
*
      IF (NKEY1.LE.2) THEN
         CALL SIC_CH (LINE,0,2,ARGUM,NA,.TRUE.,ERROR)
         IF (ERROR) RETURN
         CALL SIC_AMBIGS('PLOT',ARGUM,KEYW2,NKEY2,VOCAB2,MVOC2,ERROR)
         IF (ERROR) RETURN
         IF (KEYW1.EQ.'ERRORS') THEN
            IF (KEYW2.EQ.'AZIMUTH') THEN
               CALL PLOT_ERR_AZ
            ELSE
               CALL PLOT_ERR_EL
            ENDIF
         ELSE
            IF (KEYW2.EQ.'AZIMUTH') THEN
               CALL PLOT_RES_AZ
            ELSE
               CALL PLOT_RES_EL
            ENDIF
         ENDIF
      ELSEIF (KEYW1.EQ.'SUMMARY') THEN
         CALL PLOT_SUMMARY
      ELSEIF (KEYW1.EQ.'COVERAGE') THEN
         CALL PLOT_COVERAGE
      ELSEIF (KEYW1.EQ.'TIME') THEN
         CALL PLOT_TIME
      ELSEIF (KEYW1.EQ.'CIRCLE') THEN
         CALL PLOT_CIRCLE
      ENDIF
      END
*<FF>
      SUBROUTINE PLOT_SUMMARY
      INCLUDE 'size.inc'
      INCLUDE 'setup.inc'
      INCLUDE 'data.inc'
*
      INTEGER I
      REAL*8 ZMAX
      REAL*4 YMAX
      CHARACTER*4 CHAIN
*
      CALL GR_EXEC1('SET FONT SIMPLEX')
      CALL GR_EXEC1('SET PLOT_PAGE LANDSCAPE')
      CALL GR_EXEC1('SET BOX SQUARE')
      CALL GR_EXEC1('SET COORDINATE USER')
*
* Compute limits
      ZMAX = 0.0
      DO I=1,NDATA
         IF (DOBAD) THEN
            ZMAX = MAX(ZMAX,ABS(RESEL(I)),ABS(RESAZ(I)))
         ELSEIF (GOOD(I) .OR. GOOD(NDATA+I)) THEN
            ZMAX = MAX(ZMAX,ABS(RESEL(I)),ABS(RESAZ(I)))
         ENDIF
      ENDDO
      ZMAX = 1.1*ZMAX
      IF (ZMAX.EQ.0.0) ZMAX = 0.1
      YMAX = ZMAX
      CALL GR_LIMI (4,-YMAX,YMAX,-YMAX,YMAX)
      CALL GR_EXEC1 ('BOX')
      CALL GR_EXEC1 ('SET EXPAND 0.6')
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
            WRITE (CHAIN,'(I4)') SCAN(I)
            CALL RELOCATE (RESAZ(I),RESEL(I))
            CALL GR_LABE (CHAIN)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GR_PEN(1,2)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               WRITE (CHAIN,'(I4)') SCAN(I)
               CALL RELOCATE (RESAZ(I),RESEL(I))
               CALL GR_LABE (CHAIN)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('SET EXPAND 0.8')
      CALL GR_EXEC2 ('ELLIPSE 2/USER 0 0')
      CALL GR_EXEC2 ('ELLIPSE 5/USER 0 0')
      CALL GR_EXEC2 ('ELLIPSE 10/USER 0 0')
      CALL GR_EXEC1 ('DRAW TEXT 0 2.1 "2`" 8')
      CALL GR_EXEC1 ('DRAW TEXT 0 5.1 "5`" 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 -1.5 '//
     $'"Residual pointing errors in Azimuth (`)" 5/BOX 2')
      CALL GR_EXEC1 ('SET ORIENTATION 90')
      CALL GR_EXEC1 ('DRAW TEXT -1.5 0.0 '//
     $'"Residual pointing errors in Elevation (`)" 5/BOX 4')
      CALL GR_EXEC1 ('SET ORIENTATION 0')
      CALL GR_EXEC1 ('DRAW TEXT  0.0 0.6 '//
     $'"Residual pointing errors" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 1.2 "'//CFILE//'" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 0.6 "'//STAT_ANT//'" 6 /BOX 7')
      END
*<FF>
      SUBROUTINE PLOT_COVERAGE
      INCLUDE 'size.inc'
      INCLUDE 'setup.inc'
      INCLUDE 'data.inc'
      INCLUDE 'pi.inc'
*
      INTEGER I
      LOGICAL ERR
*
      CALL GR_EXEC1 ('LIMITS -180 180 0 90')
      CALL GR_EXEC1 ('SET PLOT_PAGE LANDSCAPE')
      CALL GR_EXEC1 ('BOX')
      CALL GR_LIMI (4,-PIS,PIS,0.0,PIS/2.)
      CALL GTSEGM('POINT',ERR)
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
*           call GR8_marker (1,azis(i),eles(i),0.0D0,-1.0D0)
            CALL GR8_MARKER (1,X(1,I),X(2,I),0.0D0,-1.0D0)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GR_PEN(1,2)
         CALL GTSEGM('BAD',ERR)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               CALL GR8_MARKER (1,X(1,I),X(2,I),0.0D0,-1.0D0)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('DRAW TEXT 0 -1.5 "Azimuth" 5/BOX 2')
      CALL GR_EXEC1 ('SET ORIENTATION 90')
      CALL GR_EXEC1 ('DRAW TEXT -1.5 0.0 "Elevation" 5/BOX 4')
      CALL GR_EXEC1 ('SET ORIENTATION 0')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 0.6 '//
     $'"Pointing sampling in Azimuth and Elevation" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 1.2 "'//CFILE//'" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 0.6 "'//STAT_ANT//'" 6 /BOX 7')
      END
*<FF>
      SUBROUTINE PLOT_ERR_AZ
      INCLUDE 'size.inc'
      INCLUDE 'setup.inc'
      INCLUDE 'data.inc'
      INCLUDE 'pi.inc'
*
      REAL*4 XMIN,XMAX
      INTEGER I
      LOGICAL ERR
*
      CALL GR_EXEC1 ('SET PLO POR')
      CALL GR_EXEC1 ('SET BOX 4 20 15 26')
      CALL LIMIPO (NDATA,FOBS,GOOD,XMIN,XMAX,DOBAD)
      CALL GR_LIMI (4,-180.0,180.0,XMIN*SECPI,XMAX*SECPI)
      CALL GR_EXEC1 ('BOX')
      CALL GR_LIMI (4,-PIS,PIS,XMIN,XMAX)
      CALL GTSEGM('POINT',ERR)
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
*           call GR8_marker (1,azis(i),eraz(i),0.0D0,-1.0D0)
            CALL GR8_MARKER (1,X(1,I),FOBS(I),0.0D0,-1.0D0)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GR_PEN(1,2)
         CALL GTSEGM('BAD',ERR)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               CALL GR8_MARKER (1,X(1,I),FOBS(I),0.0D0,-1.0D0)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('SET BOX 4 20 2 13')
      CALL GR_LIMI (4,0.0,90.0,XMIN*SECPI,XMAX*SECPI)
      CALL GR_EXEC1 ('BOX')
      CALL GR_LIMI (4,0.0,PIS/2,XMIN,XMAX)
      CALL GTSEGM('POINT',ERR)
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
            CALL GR8_MARKER (1,X(2,I),FOBS(I),0.0D0,-1.0D0)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GR_PEN(1,2)
         CALL GTSEGM('BAD',ERR)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               CALL GR8_MARKER (1,X(2,I),FOBS(I),0.0D0,-1.0D0)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('DRAW TEXT 0.0 0.75 "Azimuth" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 -1.2 "Elevation" 5/BOX 2')
      CALL GR_EXEC1 ('DRAW TEXT -0.95 2.2 "\gDA(`)" 5/BOX 4')
      CALL GR_EXEC1 ('DRAW TEXT -0.95 9.8 "\gDA(`)" 5/BOX 7')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 13.5 '//
     $'"Pointing errors in Azimuth " 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 1.2 "'//CFILE//'" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 13.5 "'//STAT_ANT//'" 6 /BOX 7')
      END
*<FF>
      SUBROUTINE PLOT_ERR_EL
      INCLUDE 'size.inc'
      INCLUDE 'setup.inc'
      INCLUDE 'data.inc'
      INCLUDE 'pi.inc'
*
      REAL*4 XMIN,XMAX
      INTEGER I
      LOGICAL ERR
*
      CALL GR_EXEC1 ('SET PLO POR')
      CALL GR_EXEC1 ('SET BOX 4 20 15 26')
      CALL LIMIPO(NDATA,FOBS(NDATA+1),GOOD,XMIN,XMAX,DOBAD)
      CALL GR_LIMI (4,-180.0,180.0,XMIN*SECPI,XMAX*SECPI)
      CALL GR_EXEC1('BOX')
      CALL GR_LIMI (4,-PIS,PIS,XMIN,XMAX)
      CALL GTSEGM('POINT',ERR)
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
*           call GR8_marker (1,azis(i),erel(i),0.0D0,-1.0D0)
            CALL GR8_MARKER (1,X(1,I),FOBS(I+NDATA),0.0D0,-1.0D0)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GR_PEN(1,2)
         CALL GTSEGM('BAD',ERR)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               CALL GR8_MARKER (1,X(1,I),FOBS(I+NDATA),0.0D0,-1.0D0)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('SET BOX 4 20 2 13')
      CALL GR_LIMI (4,0.0,90.0,XMIN*SECPI,XMAX*SECPI)
      CALL GR_EXEC1 ('BOX')
      CALL GR_LIMI (4,0.0,PIS/2,XMIN,XMAX)
      CALL GTSEGM('POINT',ERR)
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
            CALL GR8_MARKER (1,X(2,I),FOBS(I+NDATA),0.0D0,-1.0D0)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GR_PEN(1,2)
         CALL GTSEGM('BAD',ERR)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               CALL GR8_MARKER (1,X(2,I),FOBS(I+NDATA),0.0D0,-1.0D0)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('DRAW TEXT 0.0 0.75 "Azimuth" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 -1.2 "Elevation" 5/BOX 2')
      CALL GR_EXEC1 ('DRAW TEXT -0.95 2.2 "\gDE(`)" 5/BOX 4')
      CALL GR_EXEC1 ('DRAW TEXT -0.95 9.8 "\gDE(`)" 5/BOX 7')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 13.5 '//
     $'"Pointing errors in Elevation " 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 14.2 "'//CFILE//'" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 13.5 "'//STAT_ANT//'" 6 /BOX 7')
      END
*<FF>
      SUBROUTINE PLOT_RES_AZ
      INCLUDE 'size.inc'
      INCLUDE 'setup.inc'
      INCLUDE 'data.inc'
      INCLUDE 'pi.inc'
*
      REAL*4 XMIN,XMAX
      INTEGER I
      LOGICAL ERR
*
      CALL GR_EXEC1 ('SET PLO POR')
      CALL GR_EXEC1 ('SET BOX 4 20 15 26')
      CALL LIMIPO(NDATA,RESAZ,GOOD,XMIN,XMAX,DOBAD)
      CALL GR_LIMI (4,-180.0,180.0,XMIN,XMAX)
      CALL GR_EXEC1 ('BOX')
      CALL GR_LIMI (4,-PIS,PIS,XMIN,XMAX)
      CALL GTSEGM('POINT',ERR)
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
*		call GR8_marker (1,azis(i),resaz(i),0.0D0,-1.0D0)
            CALL GR8_MARKER (1,X(1,I),RESAZ(I),0.0D0,-1.0D0)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GTSEGM('BAD',ERR)
         CALL GR_SPEN(2)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               CALL GR8_MARKER (1,X(1,I),RESAZ(I),0.0D0,-1.0D0)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('SET BOX 4 20 2 13')
      CALL GR_LIMI  (4,0.0,90.0,XMIN,XMAX)
      CALL GR_EXEC1 ('BOX')
      CALL GR_LIMI  (4,0.0,PIS/2,XMIN,XMAX)
      CALL GTSEGM ('POINT',ERR)
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
            CALL GR8_MARKER (1,X(2,I),RESAZ(I),0.0D0,-1.0D0)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GTSEGM('BAD',ERR)
         CALL GR_SPEN(2)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               CALL GR8_MARKER (1,X(2,I),RESAZ(I),0.0D0,-1.0D0)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('DRAW TEXT 0.0 0.75 "Azimuth" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 -1.2 "Elevation" 5/BOX 2')
      CALL GR_EXEC1 ('DRAW TEXT -0.95 2.2 "\gDA(`)" 5/BOX 4')
      CALL GR_EXEC1 ('DRAW TEXT -0.95 9.8 "\gDA(`)" 5/BOX 7')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 13.5 '//
     $'"Residual pointing errors in Azimuth" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 14.2 "'//CFILE//'" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 13.5 "'//STAT_ANT//'" 6 /BOX 7')
      END
*<FF>
      SUBROUTINE PLOT_RES_EL
      INCLUDE 'size.inc'
      INCLUDE 'setup.inc'
      INCLUDE 'data.inc'
      INCLUDE 'pi.inc'
*
      REAL*4 XMIN,XMAX
      INTEGER I
      LOGICAL ERR
*
      CALL GR_EXEC1 ('SET PLO POR')
      CALL GR_EXEC1 ('SET BOX 4 20 15 26')
      CALL LIMIPO (NDATA,RESEL,GOOD,XMIN,XMAX,DOBAD)
      CALL GR_LIMI (4,-180.0,180.0,XMIN,XMAX)
      CALL GR_EXEC1('BOX')
      CALL GR_LIMI (4,-PIS,PIS,XMIN,XMAX)
      CALL GTSEGM  ('POINT',ERR)
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
*           call GR8_marker (1,azis(i),resel(i),0.0D0,-1.0D0)
            CALL GR8_MARKER (1,X(1,I),RESEL(I),0.0D0,-1.0D0)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GR_PEN(1,2)
         CALL GTSEGM('BAD',ERR)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               CALL GR8_MARKER (1,X(1,I),RESEL(I),0.0D0,-1.0D0)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('SET BOX 4 20 2 13')
      CALL GR_LIMI (4,0.0,90.0,XMIN,XMAX)
      CALL GR_EXEC1 ('BOX')
      CALL GR_LIMI (4,0.0,PIS/2,XMIN,XMAX)
      CALL GTSEGM('POINT',ERR)
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
            CALL GR8_MARKER (1,X(2,I),RESEL(I),0.0D0,-1.0D0)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GR_PEN(1,2)
         CALL GTSEGM('BAD',ERR)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               CALL GR8_MARKER (1,X(2,I),RESEL(I),0.0D0,-1.0D0)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('DRAW TEXT 0.0 0.75 "Azimuth" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 -1.2 "Elevation" 5/BOX 2')
      CALL GR_EXEC1 ('DRAW TEXT -0.95 2.2 "\gDE(`)" 5/BOX 4')
      CALL GR_EXEC1 ('DRAW TEXT -0.95 9.8 "\gDE(`)" 5/BOX 7')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 13.5 '//
     $'"Residual pointing errors in Elevation" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 14.2 "'//CFILE//'" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 13.5 "'//STAT_ANT//'" 6 /BOX 7')
      END
*<FF>
      SUBROUTINE PLOT_TIME
      INCLUDE 'size.inc'
      INCLUDE 'setup.inc'
      INCLUDE 'data.inc'
*
      REAL*4 XMIN,XMAX,TMIN,TMAX
      INTEGER I
      LOGICAL ERR
*
      CALL GR_EXEC1 ('SET PLO POR')
      CALL GR_EXEC1 ('SET BOX 4 20 15 26')
      CALL LIMIPO (NDATA,RESAZ,GOOD,XMIN,XMAX,DOBAD)
      CALL LIMIPO (NDATA,TIEM,GOOD,TMIN,TMAX,DOBAD)
      CALL GR_LIMI (4,TMIN,TMAX,XMIN,XMAX)
      CALL GTSEGM('POINT',ERR)
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
            CALL GR8_MARKER (1,TIEM(I),RESAZ(I),0.0D0,-1.0D0)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GR_PEN(1,2)
         CALL GTSEGM('BAD',ERR)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               CALL GR8_MARKER (1,TIEM(I),RESAZ(I),0.0D0,-1.0D0)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('BOX')
      CALL GR_EXEC1 ('SET BOX 4 20 2 13')
      CALL LIMIPO (NDATA,RESEL,GOOD,XMIN,XMAX,DOBAD)
      CALL GR_LIMI (4,TMIN,TMAX,XMIN,XMAX)
      CALL GTSEGM('POINT',ERR)
      DO I=1,NDATA
         IF (GOOD(I).OR.GOOD(NDATA+I)) THEN
            CALL GR8_MARKER (1,TIEM(I),RESEL(I),0.0D0,-1.0D0)
         ENDIF
      ENDDO
      IF (DOBAD) THEN
         CALL GR_PEN(1,2)
         CALL GTSEGM('BAD',ERR)
         DO I=1,NDATA
            IF (.NOT.(GOOD(I).OR.GOOD(NDATA+I))) THEN
               CALL GR8_MARKER (1,TIEM(I),RESEL(I),0.0D0,-1.0D0)
            ENDIF
         ENDDO
         CALL GR_PEN(1,0)
      ENDIF
      CALL GR_EXEC1 ('BOX')
*!      CALL GR_EXEC1 ('POINT')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 0.75 "Time" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 -1.2 "Time" 5/BOX 2')
      CALL GR_EXEC1 ('DRAW TEXT -0.95 2.2 "\gDE(`)" 5/BOX 4')
      CALL GR_EXEC1 ('DRAW TEXT -0.95 9.8 "\gDA(`)" 5/BOX 7')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 13.5 '//
     $'"Residual pointing errors versus Time" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 14.2 "'//CFILE//'" 5/BOX 8')
      CALL GR_EXEC1 ('DRAW TEXT 0.0 13.5 "'//STAT_ANT//'" 6 /BOX 7')
      END
*<FF>
      SUBROUTINE PLOT_CIRCLE
      INCLUDE 'size.inc'
      INCLUDE 'setup.inc'
      INCLUDE 'data.inc'
*
      INTEGER I
      REAL RAD,CRAD,SRAD,PI,RMAX,SCAL,TAILL,ERR,R,SINA,COSA,
     $X0,Y0,X1,Y1
*
      CHARACTER*2 CIJ(10)
      CHARACTER*4 CHAIN
      DATA CIJ/'0','10','20','30','40','50','60','70','80','90'/
*
      PI = ACOS(-1.0)
      CALL GR_EXEC1 ('SET PLO PORTRAIT')
      CALL GR_EXEC1 ('SET BOX_LOCATION 2 19 6 23')
      CALL GR_EXEC1 ('SET EXPAND 0.7')
      CALL GR_EXEC1 ('LIMITS 90 -90 90 -90')
      CALL GR_EXEC1 ('SET COOR USER')
      DO I = 1,10
         CALL RELOCATE(0.0D0,0.0D0)
         CALL GR_EXEC2('ELLIPSE '//CIJ(I))
         IF (I.GT.1 .AND. I.LT.10) THEN
            CALL RELOCATE (-5.0D0,-103.0D0+10.0D0*DFLOAT(I))
            CALL GR_LABE  (CIJ(I))
         ENDIF
      ENDDO
      DO I=-180,150,30
         RAD = I*PI/180.0
         SRAD = SIN(RAD)
         CRAD = COS(RAD)
         CALL RELOCATE (0.0D0,0.0D0)
         CALL DRAW (DBLE(90.0*SRAD),DBLE(90.0*CRAD))
         CALL RELOCATE (DBLE(100.0*SRAD),DBLE(100.0*CRAD))
         WRITE (CHAIN,'(I4)') I
         CALL GR_LABE (CHAIN)
      ENDDO
      CALL GR_EXEC1 ('DRAW TEXT 0 -120 "'//STAT_ANT//'" 5')
      CALL GR_EXEC1 ('DRAW TEXT 0 -110 '//
     $'"Residual pointing errors in function of Azimuth and Elevation"'
     $//' 5')
      CALL GR_EXEC1 ('DRAW MARKER 90 90')
*
      RMAX = 0.0
      DO I=1,NDATA
         ERR = SQRT(RESAZ(I)**2+RESEL(I)**2)
         RMAX= MAX(RMAX,ERR)
      ENDDO
      SCAL  = 25.0/RMAX                  ! 25 Degrees for maximum error
      TAILL = 5.0*SCAL                   ! Size of 5" marker
      CALL GR_DRAW ('ARROW',2,90.0-TAILL,90.0)
      CALL RELOCATE (90D0-0.5D0*TAILL,90.0D0)
      CALL GR_LABE_CENT(8)
      CALL GR_LABE ('5`')
      DO I=1,NDATA
         R = 90.0-180.0*X(2,I)/PI        ! Degrees
         SINA = SIN(X(1,I))
         COSA = COS(X(1,I))
         X0 = R*SINA
         Y0 = R*COSA
         X1 = X0+(RESAZ(I)*COSA-RESEL(I)*SINA)*SCAL
         Y1 = Y0-(RESAZ(I)*SINA+RESEL(I)*COSA)*SCAL
         CALL GR_DRAW ('MARKER',2,X0,Y0)
         CALL GR_DRAW ('ARROW',2,X1,Y1)
      ENDDO
      END
*<FF>
      SUBROUTINE LIMIPO (N,X,GOOD,DMIN,DMAX,BAD)
      INTEGER N
      REAL*8 X(*)
      REAL DMIN,DMAX
      LOGICAL GOOD(*),BAD
*
      INTEGER I,K
      REAL*8 XDIFF,XMIN,XMAX
      K = 0
      XMIN = 1D38
      XMAX = -1D38
      IF (BAD) THEN
         DO I=1,N
            XMIN = MIN(X(I),XMIN)
            XMAX = MAX(X(I),XMAX)
         ENDDO
         K = N
      ELSE
         DO I=1,N
            IF (GOOD(I).OR.GOOD(N+I)) THEN
               XMIN = MIN(X(I),XMIN)
               XMAX = MAX(X(I),XMAX)
               K = K+1
            ENDIF
         ENDDO
      ENDIF
      IF (K.EQ.0) THEN
         DMIN = -0.1
         DMAX =  0.1
         RETURN
      ENDIF
      IF (XMIN.LT.XMAX) THEN
         XDIFF = 0.1*(XMAX-XMIN)
      ELSEIF (XMIN.NE.0.) THEN
         XDIFF = 0.1*ABS(XMIN)
      ELSE
         XDIFF = 0.1
      ENDIF
      DMIN = XMIN-XDIFF
      DMAX = XMAX+XDIFF
      END
